Skip to content

Implement lazy loading for chaincode lifecycle cache #5258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dviejokfs
Copy link

@dviejokfs dviejokfs commented Jul 25, 2025

Type of change

  • New feature

Description

This update introduces a lazy loading feature for the chaincode lifecycle cache, allowing chaincode information to be loaded on-demand rather than pre-initialized at startup. This can significantly improve peer startup times, especially in environments with many installed chaincodes. The feature can be enabled via the core.yaml configuration file. Additionally, tests have been added to verify the behavior of the cache with lazy loading enabled.

Additional details

The implementation includes:

  • Updated NewCache function to accept a lazyLoadEnabled parameter
  • Modified InitializeLocalChaincodes to skip pre-initialization when lazy loading is enabled
  • Added new tests for lazy loading behavior in cache_test.go
  • Created documentation for lazy loading in peer_lifecycle_lazy_loading.md
  • Updated configuration example in core.yaml to include lazy loading option

This feature is particularly beneficial for peers with large numbers of installed chaincodes, as it eliminates the need to load all chaincode metadata during peer initialization, resulting in faster startup times.

Related issues

When there are a lot of chaincodes installed (10k+) peers take a long time to start since the cache is initialized. A new behaviour is needed to improve peer startup time when there are a lot of chaincodes installed.

Release Note

New Feature: Added lazy loading support for chaincode lifecycle cache to improve peer startup performance in environments with many installed chaincodes. This feature can be enabled via the core.yaml configuration file.

This update introduces a lazy loading feature for the chaincode lifecycle cache, allowing chaincode information to be loaded on-demand rather than pre-initialized at startup. This can significantly improve peer startup times, especially in environments with many installed chaincodes. The feature can be enabled via the `core.yaml` configuration file. Additionally, tests have been added to verify the behavior of the cache with lazy loading enabled.

- Updated `NewCache` function to accept a `lazyLoadEnabled` parameter.
- Modified `InitializeLocalChaincodes` to skip pre-initialization when lazy loading is enabled.
- Added new tests for lazy loading behavior in `cache_test.go`.
- Created documentation for lazy loading in `peer_lifecycle_lazy_loading.md`.
- Updated configuration example in `core.yaml` to include lazy loading option.

Signed-off-by: dviejokfs <[email protected]>
@dviejokfs dviejokfs requested review from a team as code owners July 25, 2025 10:12
Signed-off-by: dviejokfs <[email protected]>
This commit improves the lazy loading functionality by ensuring that chaincode information can be loaded on-demand when it is not pre-initialized. The changes include:

- Added logic to check and load chaincode installation information if it is nil and lazy loading is enabled.
- Updated configuration handling to support lazy loading via both `core.yaml` and environment variables.
- Introduced a new test to verify the behavior of lazy loading when enabled through environment variables.

Documentation has also been updated to reflect these changes.

Signed-off-by: dviejokfs <[email protected]>
This commit refines the lazy loading mechanism for chaincode information by enhancing the logic that checks for existing local chaincode references. Key changes include:

- Streamlined the process of finding the PackageID associated with a local chaincode definition.
- Improved handling of cases where chaincode information is not yet available, allowing for more efficient lazy loading.
- Added debug logging to provide better insights during the lazy loading process.

These updates aim to optimize the performance and reliability of the chaincode lifecycle cache.

Signed-off-by: dviejokfs <[email protected]>
This commit enhances the lazy loading mechanism for chaincode information by simplifying the conditions under which installation information is loaded. Key changes include:

- Added a check for the PackageID before attempting to load installation info on-demand.
- Streamlined the update process for local chaincode entries when installation info is retrieved.
- Improved debug logging for better traceability during the lazy loading process.

These modifications aim to optimize the efficiency and reliability of the chaincode lifecycle cache.

Signed-off-by: dviejokfs <[email protected]>
Signed-off-by: dviejokfs <[email protected]>
@kfsoftware kfsoftware closed this by deleting the head repository Aug 13, 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.

2 participants