Repository navigation
Pull optimization: reduce per-file path lookups and buffer allocations in unpackLayer - #3759
Draft
Amy (amyxu-08) wants to merge 1 commit into
Draft
Amy (amyxu-08) wants to merge 1 commit into
Amy (amyxu-08) wants to merge 1 commit into
Conversation
Change-Id: I593a1b6714fc0bc18e1ca282b427f29bf41f4cee
This branch has not been deployed
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.
Part of the optimizations outlined in Investigating Substrate Image Pull Speed
Unpacking a large image layer on a cache miss goes through redundant path lookups through
*os.Rootand uses per-file buffer allocations. For each regular file,unpackLayerwalked the path six times (MkdirAll,LstatinreplaceExisting,OpenFile,Lchown,Chmod, andChtimes) and allocated a fresh 32 KiB buffer insideio.Copywhen(*os.File).ReadFromfell back togenericReadFrom.*os.Filebefore closing it viatarutil.FchownandsetOpenFileMode.existingDirssoroot.MkdirAllruns once per parent directory, and clearexistingDirsinreplaceExisting.O_CREATE|O_WRONLY|O_EXCLand callreplaceExistingonly onos.ErrExist.outFileinwriterOnlyand pass a single 32 KiBcopyBuftoio.CopyBuffer.AI use: AI-assisted, I reviewed and tested it (
go test -race -count=3 -shuffle=on ./internal/imagecacheandhack/run-e2e.shagainst dev cluster).