-
Notifications
You must be signed in to change notification settings - Fork 0
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: packfile parsing progress #14
Conversation
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.
Leaving a couple nitty comments, should be able to dig in more tomorrow =)
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.
Re-marking points of interest for this review.
@@ -26,12 +28,30 @@ const ( | |||
|
|||
// UpdateObjectStorage updates the storer with the objects in the given | |||
// packfile. | |||
func UpdateObjectStorage(s storer.Storer, packfile io.Reader) error { | |||
func UpdateObjectStorage(s storer.Storer, packfile io.Reader, pr *progress.Reporter) error { |
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 delta { | ||
p.deltasTotal++ | ||
} |
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.
🍜 We count the total of deltas in the packfile here so that we can track progress while resolving them later.
p.objectsSeen++ | ||
p.writeObjectProgress() |
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.
This has proven to be an effective place to count objects we're receiving, but I'm realizing that this may be more of a quick enumeration than actually representative of receiving the objects. Might give this a bit more thought.
if obj.DiskType.IsDelta() { | ||
p.deltasSeen++ | ||
p.writeDeltaProgress() | ||
} |
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.
🍜 The key here was that obj.DiskType
will indicate that it's a delta, rather than using obj.Type
(for reasons I don't really understand).
} | ||
|
||
// Start begins a background process that will send periodic progress updates | ||
func (pc *Collector) Start(ctx context.Context) { |
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.
🍜
|
||
// AdvanceTime tracks the progress and returns the current rate of bytes being read | ||
// SEE: https://github.com/git/git/blob/be8661a3286c67a5d4088f4226cbd7f8b76544b0/progress.c#L186-L244 | ||
func (t *Throughput) AdvanceTime(now int64) uint64 { |
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.
🍜
First pass of add the ability to provide progress updates while parsing a packfile.
For collecting the progress while enumerating objects/deltas on a packfile as it's being parsed, as well as reporting total bytes processed and the rate of throughput.
Dynamically includes bytes received and rate
This isn't my favorite, but it helps guarantee that the collector will have a progress reporter. Added some more comments for exported things
b60a0dd
to
6b34e77
Compare
Pull Request Test Coverage Report for Build 985de556f1c4ed6e96f7675fd0efc7f3ad57e080-PR-14
💛 - Coveralls |
This PR adds the ability for go-git to provide periodic progress updates. In particular, it includes updates for:
Objects and deltas are counted while scanning and parsing packfiles
It borrows heavily from the official git implementation. Some notable points:
The client provides a progress reporter, allowing them to specify the frequency of updates and how often to poll for rate calculations. The progress reporter also has a channel to read progress updates from. After the context is canceled, the consuming code ought to be sure to finish receiving all the updates.
There's also a progress collector that's used to track all the progress data points and is ultimately responsible for sending to the progress channel.
Progress is reported using a progress update struct, and for convenience implements stringer to provide human oriented output intended to closely resemble the output of git.