Skip to content

Conversation

kayagokalp
Copy link
Member

Description

This pull request introduces a persistent CompilationCache to manage engines and compilation state across multiple sessions, enhancing the efficiency and modularity of the forc-pkg package. The changes primarily focus on integrating this cache into the build and check functions, refactoring their logic to utilize the cache, and ensuring thread-safe operations using Mutex. Below are the most important changes grouped by theme:

Introduction of CompilationCache:

  • Added CompilationCache struct: A new struct was introduced to hold engines and compilation state using Arc<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 build Function:

  • Introduced build_with_cache: A new function was added to perform package builds using the CompilationCache, replacing direct usage of Engines with cache-based operations. (forc-pkg/src/pkg.rs)
  • Replaced Engines with CompilationCache: Updated the logic in the build function to use the cache for operations like setting observers, accessing engines, and managing compilation state. (forc-pkg/src/pkg.rs) [1] [2] [3]

Refactoring check Function:

  • Introduced check_with_cache: Similar to build_with_cache, this function uses the CompilationCache for checking packages, enabling persistent state management during checks. (forc-pkg/src/pkg.rs)
  • Integrated cache into check logic: Updated check to use the cache for operations such as dependency namespace creation and AST compilation. (forc-pkg/src/pkg.rs) [1] [2]

Thread-Safety Enhancements:

  • Ensured thread-safe engine access: Replaced direct Engines usage with Mutex locks to ensure safe concurrent access to engines in both build and check functions. (forc-pkg/src/pkg.rs) [1] [2] [3]

These changes improve the modularity, maintainability, and efficiency of the forc-pkg package by introducing a persistent cache and ensuring thread-safe operations.

@kayagokalp kayagokalp self-assigned this Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant