-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
So I'm investigating this issue paritytech/substrate#11503 and as part of the investigation I had to sync a parachain node. I've noticed that after syncing a few hundred thousand blocks it got really slow, between 0~2 blocks per second. So I've fired up the profiler and I saw that the usage_info call (more specifically, the malloc_size called from StateDb::memory_info) is consuming a whopping ~25% of CPU. Whether this is actually the culprit of the slow sync or not - I'm not sure, however burning 25% of the CPU on this seems quite excessive.
Here are the four places where it's called:
-
cumulus/client/consensus/common/src/parachain_consensus.rs
- follow_finalized_head()
Calls intoUsageProvider::usage_infoonly forchain.finalized_hash, 5.1% CPU usage - handle_new_best_parachain_head()
Calls intoUsageProvider::usage_infoonly forchain.best_hash, 5.6% CPU usage
- follow_finalized_head()
-
substrate/client/service/src/metrics.rs
- run()
Calls intoBackend::usage_info, actually uses theusage, 5.4% CPU usage
- run()
-
substrate/client/informant/src/lib.rs
- build()
Calls intoBackend::usage_info, actually uses theusage, 5.4% CPU usage
- build()
The UsageProvider::usage_info() returns a ClientInfo<Block> which is:
/// Client info
#[derive(Debug)]
pub struct ClientInfo<Block: BlockT> {
/// Best block hash.
pub chain: Info<Block>,
/// Usage info, if backend supports this.
pub usage: Option<UsageInfo>,
}The Backend::usage_info returns a Option<UsageInfo>.
The two places in Cumulus don't actually need to call this as they don't actually use this information (they only care about the Info<Block> and don't use the returned UsageInfo), so that's 10% of the CPU time completely wasted.
I'm not yet sure why the underlying call to malloc_size consumes as much CPU time as it does; it might be a side effect of some more fundamental problem. Nevertheless the two calls in cumulus are at the very least completely useless and should not be made.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status