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

perf(consensus): never drop FCU #8238

Closed
wants to merge 3 commits into from
Closed

perf(consensus): never drop FCU #8238

wants to merge 3 commits into from

Conversation

emhane
Copy link
Member

@emhane emhane commented May 13, 2024

Closes #8203.

  • Adds VecDeque with engine messages to ensure no messages a dropped.

@emhane emhane added C-perf A change motivated by improving speed, memory usage or disk footprint A-consensus Related to the consensus engine labels May 13, 2024
@emhane emhane requested a review from shekhirin May 13, 2024 21:41
@github-actions github-actions bot added the C-enhancement New feature or request label May 13, 2024
@emhane
Copy link
Member Author

emhane commented May 13, 2024

wondering if it's tackling the problem at head better, to replace this with a VecDeque instead @mattsse

/// Current blockchain tree action.
blockchain_tree_action: Option<BlockchainTreeAction<EngineT>>,

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

one suggestion, but conceptionally this should be equivalent

crates/consensus/beacon/src/engine/mod.rs Outdated Show resolved Hide resolved
@mattsse
Copy link
Collaborator

mattsse commented May 14, 2024

wondering if it's tackling the problem at head better, to replace this with a VecDeque instead @mattsse

/// Current blockchain tree action.
blockchain_tree_action: Option<BlockchainTreeAction<EngineT>>,

eventually, yes, but rn this is basically just fake concurrency of sequential message processing as prep for #7154
but maybe a vecque could also work here @rkrasiuk

@shekhirin
Copy link
Collaborator

That looks good and should work.

I was only thinking maybe we should only add the messages to the queue when we actually can't process them, i.e. when the pruner is running and we skip an FCU. Instead of always caching the messages and popping them from the queue on the next poll that I think slows down the engine message processing a bit.

@emhane
Copy link
Member Author

emhane commented May 16, 2024

doesn't work though :/ @shekhirin @mattsse and not sure why, that loop is very complex

@emhane
Copy link
Member Author

emhane commented May 17, 2024

think we should rewrite this future implementation to be a stream, so we can better reason about it. rn it's very complex to create a mental model of how this state machine will behave based on varying external conditions. related #6541.

@emhane emhane requested a review from mattsse May 17, 2024 15:52
//
// These messages can affect the state of the SyncController and they're also time
// sensitive, hence they are polled first.
if let Poll::Ready(Some(msg)) = this.engine_message_stream.poll_next_unpin(cx) {
while let Some(msg) = this.queued_engine_messages.pop_front() {
Copy link
Member

Choose a reason for hiding this comment

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

the engine message processing here only sets a single action to be performed in the blockchain tree. you cannot do it in a while loop because it overwrites the last set action

Copy link
Member Author

Choose a reason for hiding this comment

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

didn't work before that commit either :/

Copy link
Member Author

Choose a reason for hiding this comment

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

@emhane
Copy link
Member Author

emhane commented May 20, 2024

closing in favour of #8315

@emhane emhane closed this May 20, 2024
@emhane emhane deleted the emhane/cache-fcu branch May 27, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine C-enhancement New feature or request C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Buffer incoming engine messages if pruner is active
4 participants