Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Alternate push bug fix#1762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cedric-appdirect wants to merge3 commits intogo-git:main
base:main
Choose a base branch
Loading
fromcedric-appdirect:alternate-push-bug

Conversation

@cedric-appdirect
Copy link

This started with a massive memory spike when pushing a single change on a repository using alternate. Issue was due to continuous creation of NewObjectStorage. Additionally I realized that when doing a Clone it was doing a very large amount of data transfer as it wasn't able to find the hash from the alternate as it wasn't doing the lookup at all.

I think the code could be better if I was to use range-over-func, but I am not sure that is ok pattern for this repository. Let me know if that would be preferred or if you have any better idea on how to implement this.

Problem:When looking up objects via alternates, the current implementation createsa new ObjectStorage instance for every lookup. This causes severe performancedegradation because each NewObjectStorage() call re-reads the alternates file,re-initializes packfile index structures, and re-loads packfile indexes.For operations that enumerate many objects (push, log, diff), this causes formy test repository with 35K files:- 500+ GB memory allocation (repeatedly loading indexes)- 195+ seconds CPU time for object enumeration- Massive disk I/O (re-reading same packfiles)Benchmarks show git push with alternates is 173x slower than git CLIon a repository with 35K files.Solution:Cache ObjectStorage instances for alternate repositories using sync.Oncefor thread-safe lazy initialization. The cached instances share the sameobjectCache to maximize cache hits across all storages.This fix also extends alternates support to HasEncodedObject andEncodedObjectSize methods which previously did not check alternates.Performance impact:- Object lookups via alternates: ~100x faster- Memory usage: ~500x reduction per lookup- Push operation on 35k file repo: 287s to ~20sSigned-off-by: Cedric BAIL <cedric.bail@appdirect.com>
Add comprehensive tests for the alternates caching functionality:- TestObjectStorageMultipleAlternates: verify multiple alternates work- TestObjectStorageAlternatesHasEncodedObject: verify HasEncodedObject- TestObjectStorageAlternatesEncodedObjectSize: verify EncodedObjectSizeSigned-off-by: Cedric BAIL <cedric.bail@appdirect.com>
Add benchmarks to measure and prevent regression in alternatesperformance using b.Run sub-benchmarks and modern b.Loop():- BenchmarkAlternatesObjectLookup/EncodedObject- BenchmarkAlternatesObjectLookup/HasEncodedObject- BenchmarkAlternatesObjectLookup/EncodedObjectSizeThese benchmarks document the expected performance characteristicsand help catch regressions in future changes.Note: PlainClone with Shared:true cannot be used here due to importcycle (repository.go imports storage/filesystem), so alternatesare set up manually following the same pattern.Signed-off-by: Cedric BAIL <cedric.bail@appdirect.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@cedric-appdirect

[8]ページ先頭

©2009-2025 Movatter.jp