This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
BEEFY: optimize voter event loop for fewer 'active' wakeups #12759
Closed
Description
Issue
Doing a bit of profiling showed BeefyWorker::run() async task being "active" more than it should, waking up many times even when there haven't been any external events relevant to the voter logic.
Investigating this showed the "culprit" to be listening for network-gossip
events in the main async loop. Even if the "interesting" events are only NetEvent::SyncConnected
and NetEvent::SyncDisconnected
, the BEEFY voter actually wakes up and (uselessly) tries to vote for all network events (which are many!)
Proposed fix
Move network peers tracking to the much lighter BeefyJustifsRequestHandler::run() task (which is also the user of the connected peer set); thus massively decreasing wake-up rate of the heavier BEEFY voter task.