Optimize peer startup by avoiding unnecessary chaincode package reads#5418
Open
C0rWin wants to merge 1 commit intohyperledger:mainfrom
Open
Optimize peer startup by avoiding unnecessary chaincode package reads#5418C0rWin wants to merge 1 commit intohyperledger:mainfrom
C0rWin wants to merge 1 commit intohyperledger:mainfrom
Conversation
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>
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.
During startup
InitializeLocalChaincodes()reads and fully parses every installed chaincode tar.gz — two gzip decompressions per package — only to extractPackageID,Label,Type, andPath. Of these,PackageIDandLabelare already available from the filename (<label>.<sha256hash>.tar.gz), andType/Pathhave no consumers anywhere in the codebase. With 500+ installed packages this takes around 5 minutes.This change skips
Store.Load()andPackageParser.Parse()during startup and uses the metadata thatListInstalledChaincodes()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.