-
Notifications
You must be signed in to change notification settings - Fork 534
packfile: create packfile.Index and reuse it #510
Conversation
This is the first PR in a series of 3 to improve performance on various operations, including push. This index structure is required to improve caching and reusing deltas (next 2 PRs). |
@smola CI |
plumbing/format/packfile/decoder.go
Outdated
func (d *Decoder) Offsets() map[plumbing.Hash]int64 { | ||
return d.hashToOffset | ||
// SetIndex sets an index for the packfile. It is recommended to set this. | ||
// The index might be read from a file or reused from a previous Decoer usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decoer -> Decoder
plumbing/format/packfile/index.go
Outdated
|
||
// FromIdxFile takes an idxfile.Idxfile and adds its entries to the current | ||
// index. The current index will be emptied before adding the new entries. | ||
func (idx *Index) FromIdxFile(idxf *idxfile.Idxfile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If each Index
is only intended to be used on one packfile, Should this method be a constructor?
There was an internal type (i.e. storage/filesystem.idx) to use as in-memory index for packfiles. This was not convenient to reuse in the packfile. This commit creates a new representation (format/packfile.Index) that can be converted to and from idxfile.Idxfile. A packfile.Index now contains the functionality that was scattered on storage/filesystem.idx and packfile.Decoder's internals. storage/filesystem now reuses packfile.Index instances and this also results in higher cache hit ratios when resolving deltas.
Codecov Report
@@ Coverage Diff @@
## master #510 +/- ##
==========================================
- Coverage 78.29% 77.76% -0.54%
==========================================
Files 127 128 +1
Lines 9428 9455 +27
==========================================
- Hits 7382 7353 -29
- Misses 1240 1311 +71
+ Partials 806 791 -15
Continue to review full report at Codecov.
|
There was an internal type (i.e. storage/filesystem.idx) to
use as in-memory index for packfiles. This was not convenient
to reuse in the packfile.
This commit creates a new representation (format/packfile.Index)
that can be converted to and from idxfile.Idxfile.
A packfile.Index now contains the functionality that was scattered
on storage/filesystem.idx and packfile.Decoder's internals.
storage/filesystem now reuses packfile.Index instances and this
also results in higher cache hit ratios when resolving deltas.