-
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: Replace some uses of engine.Unit with ComponentManager #6833
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using #4219 as an example. Instead of starting new goroutines or directly processing messages in a blocking way, messages are added to a queue that a worker pulls from. The Pusher engine still currently implements network.Engine rather than network.MessageProcessor.
Because the event processing now happens in a worker, any errors raised within it are no longer visible to the caller of Process(). Because the test checked for error status, moved the tests to the same package and call the internal processing function directly.
When using Unit, calling Ready would also start the engine. With ComponentManager, we additionally need to invoke Start.
Rename `inboundMessageWorker` and `processInboundMessages` to `outbound` and also propagate errors to the top level of the worker where they can be thrown.
- Partially implement suggestion #6747 (comment) - Make `SubmitCollectionGuarantee` non-exported and rename to `publishCollectionGuarantee` - Add new `SubmitCollectionGuarantee` exported function that just adds to the queue - Remove `messageHandler` field, instead directly add to queue from review: #6747 (comment) - `OriginID`s no longer included in messages in the queue, and therefore not checked by the worker - if necessary they should be checked when Submitting
This reverts commit 0aadc13. Instead of testing the internals, test the exported interface.
…gine-use-componentmanager
Rename queue and add length metrics for it, updating creation sites.
Co-authored-by: Alexander Hentschel <[email protected]>
Doc comment changes, metrics naming, and queue length. For reasoning behind chosen queue length, see #6747 (comment) Co-authored-by: Jordan Schalm <[email protected]>
Instead of logging an error, add to the metrics when the queue is full and a message needs to be dropped instead of sent. https://github.com/onflow/flow-go/blob/85913ad09e605fb5234155301bb0d517946a75a5/engine/collection/compliance/engine.go#L139-L146
…nentmanager Refactor pusher engine part 1 replace engine.Unit with ComponentManager in Pusher Engine
- Remove pusher engine implementation of network.Engine - Replace with network.MessageProcessor - See: #6747 (comment) - Remove SubmitCollectionGuarantee message type - Was only used between Finalizer and Pusher engine - New interface passes and stores collection guarantees directly, instead of wrapping and then unwrapping them - See: #6747 (comment) - Add GuaranteedCollectionPublisher interface, implemented by pusher engine - Only used by the Finalizer (and intermediate constructors) - Mocks are generated for it, used in Finalizer unit tests - See: #6747 (comment)
- Construct the mock objects with their `.New___()` method instead of using golang's built-in `new` function, which enables automatic cleanup. - Replace explicit AssertCalled checks at the end of tests with .On() and .Once() which will automatically be checked at the end of the test.
Co-authored-by: Jordan Schalm <[email protected]>
Improve documentation for Process method of pusher engine, and log an error instead of returning an error. See: #6780 (comment) Co-authored-by: Alexander Hentschel <[email protected]>
…terface Refactor Pusher Engine (part 2) - updated interface
The engine.Unit was only used for its context. In similar situations, other code uses a context.Background() instead.
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.
Update/clarify doc comments Co-authored-by: Jordan Schalm <[email protected]>
…move-Unit Remove engine.Unit from Assigner engine and Fetcher engine
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
…it-refactor Refactor AsyncUploader to replace Engine.Unit with ComponentManager
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6833 +/- ##
==========================================
- Coverage 41.26% 41.22% -0.04%
==========================================
Files 2061 2108 +47
Lines 182702 186136 +3434
==========================================
+ Hits 75384 76737 +1353
- Misses 101010 102999 +1989
- Partials 6308 6400 +92
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
tim-barry
requested review from
zhangchiqing and
jordanschalm
as code owners
December 20, 2024 22:17
zhangchiqing
approved these changes
Dec 20, 2024
jordanschalm
approved these changes
Dec 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only contains changes from previously-reviewed PRs: #6747, #6780, #6808, and #6809, covering the Collection node Pusher engine, Verification node Assigner/Fetcher engines, and Execution node AsyncUploader.
Part of #6807.