-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Progress callbacks #990
Progress callbacks #990
Conversation
data->found_submodules = true; | ||
data->num_stages = 3; |
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.
It seems that this could come fairly late in the checkout process (always in the second stage? possibly as the very last item of the second stage?) Is it possible that progress could jump back quite a bit? (say, from ~100% to ~66% in the worst case...)?
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.
It actually hits somewhere in the first stage, while missing items are being created. And yeah, I've seen the progress jump back from 50% to 33%. Is this better or worse than having an instantaneous jump from 66% to 100%?
We could also weight the third stage to be 10% of the total and always include it. It's only creating a relatively small number of directories, and I doubt we'll be implementing anything that includes fetching and checking out the submodules.
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.
I think having progress jump backwards is very problematic. It seems vastly preferable to have it jump forward. Imagine this being displayed as a progress bar in the UI. A backwards jump is not good a nice user experience.
By the way, I actually think as implemented, this jump will happen somewhere during the second phase (first phase is removing files). You can move the jump to the first phase by replicating the "is there a submodule that would need to be checked out" logic while scanning through the deletes, but I opted not to do that since I knew that further rethinking of the progress reporting would still be yet to come.
Another alternative is to exclude the third pass from the progress reporting completely since it just calls mkdir on the submodule. We could then require an explicit call to checkout submodules and/or add a submodule callback a la the notification callback.
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.
Yeah, the time spent doing mkdir is probably negligible. I'll weight that stage to 0%. 😉
Thanks Ben! I think this looks pretty good to me! Just two small question on the progress value calculation.
|
Thanks for the review!
|
Also removing all the *stats parameters from external APIs that don't need them anymore.
Also converted the network example to use it.
git_index_read_tree() was exposing a parameter to provide the user with a progress indicator. Unfortunately, due to the recursive nature of the tree walk, the maximum number of items to process was unknown. Thus, the indicator was only counting processed entries, without providing any information how the number of remaining items.
Also implemented in the git2 example.
The fetch code takes advantage of this to implement a progress callback every 100kb of transfer.
Also, now only reporting checkout progress for files that are actually being added or removed.
There, I switched the checkout callbacks to current/total. I've also added a network-transfer callback for when you're fetching large objects (try |
The only thing would be that the callback and |
The callback gets an accumulated number of bytes that's been returned from |
I think this is ready. Any more commentary? |
git_repository **out, | ||
const char *origin_url, | ||
const char *dest_path, | ||
git_indexer_progress_callback fetch_progress_cb, |
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 irks me. Is indexer_progress
the right name for a callback that will also report network operations?
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.
git_fetch_progress_callback
?git_network_progress_callback
?git_something_happened_update_your_ui
?
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.
Also: git_indexer_stats
is used to report network-transfer progress. Just sayin.
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.
There, I changed everything that was git_indexer_*
to git_transfer_progress_*
, and sane-ified the progress member naming. What do you think?
I guess consumers could read the |
git_indexer_stats and friends -> git_transfer_progress* Also made git_transfer_progress members more sanely named.
@jamill: how would you feel if I nuked |
👍 I think that makes sense. The other reference parameters have already been removed. I think it would be consistent to remove |
Progress callbacks
Fetch, checkout, and clone currently report progress through a shared memory object, which requires a two-thread arrangement on the caller's side. This is a generally good idea, but not especially friendly to bindings.
This PR converts these three APIs to use inline callbacks for reporting progress, so no threading is necessary. It probably accomplishes the same goal as #890, and in a more binding-friendly way.