-
Notifications
You must be signed in to change notification settings - Fork 3
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
Use only one rpc client at time #612
Conversation
This reverts commit 02562ef.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Did you measure startup time and resource usage vs before this change ?
essentials/src/api/executor.rs
Outdated
} | ||
|
||
impl RequestExecutorError { | ||
pub fn should_repeat(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn should_repeat(&self) -> bool { | |
pub fn should_retry(&self) -> bool { |
essentials/src/api/executor.rs
Outdated
|
||
loop { | ||
tokio::select! { | ||
message = from_frontend.recv() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't really need a select!
here, you can just let message = from_frontend.recv().await
} | ||
} | ||
|
||
pub trait RequestExecutorNodes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit slow to understand what does the String
represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it the rpc node url ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It's a bit odd way to allow pass different types of node urls as an argument.
essentials/src/api/executor.rs
Outdated
) { | ||
let client = match build_client(&url, api_client_mode, &self.retry).await { | ||
Some(v) => v, | ||
None => return, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we log an error here ?
Changes have been made to improve the stability of the subxt client (including the light client mode). It's done in two specific parts.
Updated subxt client implementation
We used to spawn a client for a number of watched parachains or even more. Despite the memory and CPU usage it was a working approach until we decided to switch to a light client instead of a full RPC node. Spawning a light client for each parachain leads to overuse of resources and as a result - crashes the entire application.
What changed:
Improved rpc node requests
Implementing the new subxt client revealed a hidden problem with the number of requests. One client was unable to process all requests at the same speed as many clients and became a bottleneck. After investigation it was found that the most common request is to check the HRMP channels of a given parachain (about 80%).
We used to fetch the ingress and egress channel index of each parachain and then check each channel. It could be optimized because most of the attempts were empty, i.e. not every open channel was used to send a message in a given block.
What changed:
New implementation of HRMP channel requesting works well with a full RPC node, but light client can't hold that load. Since we currently only display HRMP metrics in CLI mode and don't send them to Prometheus, we decided to make them optional for a while. More work on improving HRMP fetching on the light client is coming.
Results
Processing of HRMP channels for one block, while watching all parachains in the Polkadot network.
Memory usage, 5 minutes while watching all parachains in the Polkadot network.