Skip to content

Optimize peer startup by avoiding unnecessary chaincode package reads#5418

Open
C0rWin wants to merge 1 commit intohyperledger:mainfrom
C0rWin:chaincode-cache-load-opt
Open

Optimize peer startup by avoiding unnecessary chaincode package reads#5418
C0rWin wants to merge 1 commit intohyperledger:mainfrom
C0rWin:chaincode-cache-load-opt

Conversation

@C0rWin
Copy link
Contributor

@C0rWin C0rWin commented Mar 14, 2026

During startup InitializeLocalChaincodes() reads and fully parses every installed chaincode tar.gz — two gzip decompressions per package — only to extract PackageID, Label, Type, and Path. Of these, PackageID and Label are already available from the filename (<label>.<sha256hash>.tar.gz), and Type/Path have no consumers anywhere in the codebase. With 500+ installed packages this takes around 5 minutes.

This change skips Store.Load() and PackageParser.Parse() during startup and uses the metadata that ListInstalledChaincodes() already extracts from filenames. The full package is still read lazily when actually needed — during chaincode build, runtime install, or DB artifact extraction. No changes to any other code paths.

During peer startup, InitializeLocalChaincodes previously read and
fully parsed every installed chaincode tar.gz archive (double gzip
decompression) only to extract metadata that is either already
available from the filename or unused by any downstream consumer.

Use the label and package ID already provided by
ListInstalledChaincodes (extracted from the filename via regex)
instead of calling Store.Load and PackageParser.Parse for each
package. The Type and Path fields from ChaincodePackageMetadata
have no readers in the codebase and are left empty.

For peers with 500+ installed chaincodes this reduces startup time
from ~5 minutes to under a second.

Signed-off-by: Artem Barger <artem@bargr.net>
@C0rWin C0rWin requested a review from a team as a code owner March 14, 2026 14:13
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