Skip to content

cache implied directory parent during unpack - #112

Closed
crazy-max wants to merge 1 commit into
moby:mainfrom
crazy-max:cache-implied-directory-parent
Closed

cache implied directory parent during unpack#112
crazy-max wants to merge 1 commit into
moby:mainfrom
crazy-max:cache-implied-directory-parent

Conversation

@crazy-max

Copy link
Copy Markdown
Member

Avoid repeated parent directory checks for consecutive archive entries that share the same implicit parent.

Clear the cache after extraction-side removals so whiteouts and replacements cannot reuse stale parent state. Add a whiteout regression test and benchmarks for the implied-directory path.

$ go test . -run ^$ -bench BenchmarkCreateImpliedDirectoriesSameParent -benchmem -count=5
goos: darwin
goarch: arm64
pkg: github.com/moby/go-archive
cpu: Apple M3 Max
BenchmarkCreateImpliedDirectoriesSameParent/uncached-14                    66552             15672 ns/op             271 B/op          5 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/uncached-14                    70644             16508 ns/op             271 B/op          5 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/uncached-14                    74014             16599 ns/op             271 B/op          5 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/uncached-14                    73827             16483 ns/op             271 B/op          5 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/uncached-14                    73699             16613 ns/op             271 B/op          5 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/cached-14                   48969264                24.03 ns/op            0 B/op          0 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/cached-14                   48283262                23.91 ns/op            0 B/op          0 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/cached-14                   49352673                24.08 ns/op            0 B/op          0 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/cached-14                   50833365                24.04 ns/op            0 B/op          0 allocs/op
BenchmarkCreateImpliedDirectoriesSameParent/cached-14                   50965332                23.81 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/moby/go-archive      13.154s

Avoid repeated parent directory checks for consecutive archive entries
that share the same implicit parent.

Clear the cache after extraction-side removals so whiteouts and replacements
cannot reuse stale parent state. Add a whiteout regression test and
benchmarks for the implied-directory path.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.35%. Comparing base (e738eed) to head (8f8d61d).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
diff.go 57.14% 1 Missing and 2 partials ⚠️
archive.go 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   65.25%   65.35%   +0.10%     
==========================================
  Files          46       46              
  Lines        2377     2390      +13     
==========================================
+ Hits         1551     1562      +11     
  Misses        606      606              
- Partials      220      222       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@crazy-max
crazy-max requested review from thaJeztah and vvoland August 13, 2026 08:22
@crazy-max
crazy-max marked this pull request as ready for review August 13, 2026 08:25
@vvoland

vvoland commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

While reviewing I thought about a bit simpler solution without having to maintain the mutable cache.. See #113. Let me know if it looks better to you as well

@crazy-max
crazy-max deleted the cache-implied-directory-parent branch August 14, 2026 14:20
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.

3 participants