-
Notifications
You must be signed in to change notification settings - Fork 180
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
Refactor AsyncUploader to replace Engine.Unit with ComponentManager #6809
Refactor AsyncUploader to replace Engine.Unit with ComponentManager #6809
Conversation
Replace engine.Unit with component.Component - Arbitrarily set number of workers to 3 Uses a fifoqueue to buffer tasks (planned to replace with channel, since we would rather wait to upload than let a block be not uploaded). Does not correctly propagate errors, or calculate any new metrics yet.
BadgerRetryableUploadWrapper wraps an AsyncUploader. Now that the AsyncUploader is a Component, it needs to be `Start()`ed. The retryable wrapper did not itself do anything special on ready/done, so the Component functionality is directly delegated to the wrapped AsyncUploader.
Since AsyncUploader now implements Component instead of ReadyDoneAware, update the methods used to start and end the AsyncUploader (using a context and its cancel() function). Test "uploads are run in parallel" currently failing (due to only one worker taking tasks from the queue?)
Instead of using a notifier and fifoqueue with metrics, use a buffered channel. Block when the channel is full. (Reasoning: we want to ensure no uploads get dropped.) Buffer size of 100 was chosen arbitrarily. All AsyncUploader tests now pass.
Because Component's `Ready()` and `Done()` methods work differently from ReadyDoneAware's, include them in Component with Component-specific comments. Namely, specify that Components should be started with Start() and shutdown by canceling the context they were started with.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/pusher-engine-refactor #6809 +/- ##
==================================================================
- Coverage 41.25% 41.24% -0.01%
==================================================================
Files 2062 2062
Lines 182730 182742 +12
==================================================================
- Hits 75383 75375 -8
- Misses 101033 101051 +18
- Partials 6314 6316 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
One thing I haven't done anything about yet - we might want to rewrite the AsyncUploader tests to make more use of testing utility functions for ensuring synchronization / counting function calls, rather than explicitly use waitgroups all the time. Something to consider, though the synchronization behaviour of some of the current tests seems a bit complex. |
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.
Nice work, and thank you for updating the Ready
/Done
method documentation.
Update/clarify doc comments Co-authored-by: Jordan Schalm <[email protected]>
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.
Left 2 comments for the parameters. Other than that looks good.
I also wonder if it can be merged to master
instead of pusher-engine-refactor
.
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 agree with the existing comments about the queue size and worker count. otherwise, this looks good to me
Co-authored-by: Jordan Schalm <[email protected]>
Channel size of 20000 and worker count of 100 suggested by Leo. 20000 is approximately equal to 4 hours of execution results. Co-authored-by: Leo Zhang <[email protected]>
…ader-engine.Unit-refactor
AsyncUploader now uses the Component interface, and a channel is used to buffer upload tasks until a worker goroutine is available to begin the upload.
In addition, updated documentation comments for the Component interface to clarify differences from ReadyDoneAware.
Part of #6807.