Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces a persistent
CompilationCacheto manage engines and compilation state across multiple sessions, enhancing the efficiency and modularity of theforc-pkgpackage. The changes primarily focus on integrating this cache into thebuildandcheckfunctions, refactoring their logic to utilize the cache, and ensuring thread-safe operations usingMutex. Below are the most important changes grouped by theme:Introduction of
CompilationCache:CompilationCachestruct: A new struct was introduced to hold engines and compilation state usingArc<Mutex<Engines>>. It includes methods for managing engines, clearing programs/modules, setting observers, and executing functions with locked engines. (forc-pkg/src/pkg.rs)Refactoring
buildFunction:build_with_cache: A new function was added to perform package builds using theCompilationCache, replacing direct usage ofEngineswith cache-based operations. (forc-pkg/src/pkg.rs)EngineswithCompilationCache: Updated the logic in thebuildfunction to use the cache for operations like setting observers, accessing engines, and managing compilation state. (forc-pkg/src/pkg.rs) [1] [2] [3]Refactoring
checkFunction:check_with_cache: Similar tobuild_with_cache, this function uses theCompilationCachefor checking packages, enabling persistent state management during checks. (forc-pkg/src/pkg.rs)checklogic: Updatedcheckto use the cache for operations such as dependency namespace creation and AST compilation. (forc-pkg/src/pkg.rs) [1] [2]Thread-Safety Enhancements:
Enginesusage withMutexlocks to ensure safe concurrent access to engines in bothbuildandcheckfunctions. (forc-pkg/src/pkg.rs) [1] [2] [3]These changes improve the modularity, maintainability, and efficiency of the
forc-pkgpackage by introducing a persistent cache and ensuring thread-safe operations.