Skip to content
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

Merged
merged 16 commits into from
Mar 25, 2020
Merged

Conversation

johncoder
Copy link

@johncoder johncoder commented Mar 13, 2020

This PR adds the ability for go-git to provide periodic progress updates. In particular, it includes updates for:

  • Receiving objects (count, max, and percentage)
  • Bytes received and rate of throughput
  • Resolving deltas (count, max)

Objects and deltas are counted while scanning and parsing packfiles

It borrows heavily from the official git implementation. Some notable points:

  • IEC values for human readable bytes and throughput
  • Rate is calculated with a ring buffer that polls periodically. In places of timers and signals used by git, we're using goroutines.

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.

@johncoder johncoder marked this pull request as ready for review March 18, 2020 21:38
options.go Outdated Show resolved Hide resolved
plumbing/format/packfile/common.go Outdated Show resolved Hide resolved
plumbing/format/packfile/parser.go Outdated Show resolved Hide resolved
plumbing/format/packfile/parser.go Outdated Show resolved Hide resolved
plumbing/progress/throughput.go Show resolved Hide resolved
plumbing/progress/progress_collector.go Outdated Show resolved Hide resolved
plumbing/format/packfile/parser.go Outdated Show resolved Hide resolved
plumbing/format/packfile/parser.go Outdated Show resolved Hide resolved
plumbing/format/packfile/scanner.go Outdated Show resolved Hide resolved
Copy link

@davetakahashi-abstract davetakahashi-abstract left a 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 =)

plumbing/format/packfile/common.go Outdated Show resolved Hide resolved
plumbing/progress/progress_collector.go Outdated Show resolved Hide resolved
plumbing/progress/progress_collector.go Outdated Show resolved Hide resolved
plumbing/progress/progress_collector.go Outdated Show resolved Hide resolved
plumbing/progress/progress_collector.go Outdated Show resolved Hide resolved
Copy link
Author

@johncoder johncoder left a 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 {
Copy link
Author

Choose a reason for hiding this comment

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

🍜

Comment on lines +282 to +284
if delta {
p.deltasTotal++
}
Copy link
Author

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.

Comment on lines +288 to +289
p.objectsSeen++
p.writeObjectProgress()
Copy link
Author

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.

Comment on lines +304 to +307
if obj.DiskType.IsDelta() {
p.deltasSeen++
p.writeDeltaProgress()
}
Copy link
Author

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) {
Copy link
Author

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 {
Copy link
Author

Choose a reason for hiding this comment

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

🍜

John Nelson added 16 commits March 23, 2020 09:25
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
+ Refactored all the progress stuff out of scanner into parser
+ Eliminated package name stuttering
+ Fixed possible nil pointer
This isn't my favorite, but it helps guarantee that the collector will
have a progress reporter.

Added some more comments for exported things
@johncoder johncoder force-pushed the feat/packfile-scanner-progress branch from b60a0dd to 6b34e77 Compare March 23, 2020 14:28
@github-actions
Copy link

Pull Request Test Coverage Report for Build 985de556f1c4ed6e96f7675fd0efc7f3ad57e080-PR-14

  • 0 of 243 (0.0%) changed or added relevant lines in 10 files are covered.
  • 32 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 0.366%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plumbing/transport/server/server.go 0 1 0.0%
plumbing/transport/test/upload_pack.go 0 1 0.0%
remote.go 0 1 0.0%
storage/filesystem/dotgit/writers.go 0 1 0.0%
repository.go 0 7 0.0%
plumbing/progress/reporter.go 0 10 0.0%
storage/filesystem/object.go 0 12 0.0%
plumbing/progress/throughput.go 0 32 0.0%
plumbing/progress/update.go 0 73 0.0%
plumbing/progress/collector.go 0 105 0.0%
Files with Coverage Reduction New Missed Lines %
storage/filesystem/storage.go 2 0%
internal/revision/parser.go 30 0%
Totals Coverage Status
Change from base Build f1c004ce258021316769bc15d5bf72c390568812: -0.02%
Covered Lines: 64
Relevant Lines: 17504

💛 - Coveralls

@johncoder johncoder merged commit 2eaa71a into master Mar 25, 2020
@johncoder johncoder deleted the feat/packfile-scanner-progress branch March 25, 2020 19:05
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