Skip to content

Compact tail packfiles#376

Open
mathieu-plak wants to merge 2 commits into
mainfrom
mm/compact_tail_packfiles
Open

Compact tail packfiles#376
mathieu-plak wants to merge 2 commits into
mainfrom
mm/compact_tail_packfiles

Conversation

@mathieu-plak

Copy link
Copy Markdown
Contributor

This adds compaction of tail packfiles in order to minimize the number of non-full packfiles we create

Still a draft as I want to measure performance with high concurrency number (thing like maxConcurrency set to 1000) and the on disk packfiles, just to be sure those ReadAt won't be too much. It's a one time thing so it shouldn't be too bad.

@mathieu-plak
mathieu-plak marked this pull request as draft May 12, 2026 15:17
Base automatically changed from mm/fix_end_padding to main May 12, 2026 15:30
@mathieu-plak
mathieu-plak force-pushed the mm/compact_tail_packfiles branch from 76636ff to 1df0575 Compare May 12, 2026 15:33
* Let's you iterate over the content of a packfile (index+associated
  data). On disk this is not the most efficient version but it ougth to
  be enough.

* This will be used to implement compaction of tail pages.
@mathieu-plak
mathieu-plak force-pushed the mm/compact_tail_packfiles branch from 1df0575 to 8c486dc Compare May 15, 2026 13:10
* Because we pin one packfile per chunking goroutine, at the end of a
  run we possibly end up with a lot of really small packfiles. This
  create unecessary cruft (both in state and in the repo).

* In order to mitigate this, when the run is ending we add a merge phase
  where we compact those packfiles into as little as possible.
@mathieu-plak
mathieu-plak force-pushed the mm/compact_tail_packfiles branch from 8c486dc to 5a79402 Compare May 15, 2026 14:17
@mathieu-plak
mathieu-plak marked this pull request as ready for review May 15, 2026 14:17

@omar-polo omar-polo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread packfile/packfile_mem.go
Comment on lines +347 to +348
out := make([]byte, b.Length)
copy(out, p.Blobs[b.Offset:b.Offset+uint64(b.Length)])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a question to validate my understanding: you're doing this to stay on the safe side, and because this is not particularly performance-sensitive (done once at the end) right?

because in theory, we could just pass a slice on p.Blobs, correct?

@poolpOrg poolpOrg added this to the v1.2.0 milestone Jun 15, 2026
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