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

Refactor AsyncUploader to replace Engine.Unit with ComponentManager #6809

Conversation

tim-barry
Copy link
Contributor

@tim-barry tim-barry commented Dec 12, 2024

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.

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-commenter
Copy link

codecov-commenter commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 89.13043% with 5 lines in your changes missing coverage. Please review.

Project coverage is 41.24%. Comparing base (2e6fc67) to head (955373a).

Files with missing lines Patch % Lines
engine/execution/ingestion/uploader/uploader.go 88.88% 3 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
unittests 41.24% <89.13%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tim-barry tim-barry marked this pull request as ready for review December 13, 2024 17:57
@tim-barry
Copy link
Contributor Author

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.

Copy link
Member

@jordanschalm jordanschalm left a 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.

engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
module/component/component.go Outdated Show resolved Hide resolved
module/component/component.go Outdated Show resolved Hide resolved
module/component/component.go Outdated Show resolved Hide resolved
engine/execution/ingestion/uploader/uploader_test.go Outdated Show resolved Hide resolved
engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
Update/clarify doc comments

Co-authored-by: Jordan Schalm <[email protected]>
module/component/component.go Outdated Show resolved Hide resolved
engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
Copy link
Member

@zhangchiqing zhangchiqing left a 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.

engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
engine/execution/ingestion/uploader/uploader.go Outdated Show resolved Hide resolved
Copy link
Contributor

@peterargue peterargue left a 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

tim-barry and others added 3 commits December 20, 2024 10:03
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]>
@tim-barry tim-barry merged commit 266ad1f into feature/pusher-engine-refactor Dec 20, 2024
55 checks passed
@tim-barry tim-barry deleted the tim/6807-AsyncUploader-engine.Unit-refactor branch December 20, 2024 20:25
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.

5 participants