-
Notifications
You must be signed in to change notification settings - Fork 695
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
backing: improve session buffering for runtime information #6284
Conversation
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.
Thank you! Looking good so far! Let's see what else we can cache 😄
…d caching for node_features, minimum_backing_votes and validator_to_group mapping
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.
A couple of small suggestions left. Let's also add a prdoc. Thanks!
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.
code looks good, but I would suggest to move the implementation to the general purpose one we already have.
} | ||
} | ||
|
||
impl PerSessionCache { |
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.
Note that we already have such a cache:
pub struct RuntimeInfo { |
@eskimor, I would suggest merging this PR first as it is, since there are already multiple subsystems doing their own caching and it was also a learning experience for @sw10pa as his first PR. The |
@@ -105,6 +105,9 @@ pub enum Error { | |||
|
|||
#[error("Availability store error")] | |||
StoreAvailableData(#[source] StoreAvailableDataError), | |||
|
|||
#[error("Data is not available")] | |||
DataNotAvailable, |
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.
This doesn't say anything
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.
For a temporary solution, I have changed the name and description of the error but, as discussed separately, will try to replace RuntimeApiErrors with Subsystem errors in a separate PR.
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.
} | ||
|
||
/// Gets validators from the cache or fetches them from the runtime if not present. | ||
async fn get_or_fetch_validators( |
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.
Given that this is a cache struct, the function names are overly verbose. I'd suggest just validators()
, node_fetures()
, executor_params
.
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.
Renamed.
Issue
[#3421] backing: improve session buffering for runtime information
Description
In the current implementation of the backing module, certain pieces of information, which remain unchanged throughout a session, are fetched multiple times via runtime API calls. The goal of this task was to introduce a local cache to store such session-stable information and perform the runtime API call only once per session.
This PR implements caching specifically for the validators list, node features, executor parameters, minimum backing votes threshold, and validator-to-group mapping, which were previously fetched from the runtime or computed each time
PerRelayParentState
was built. Now, this information is cached and reused within the session.TODO
For the next PR
Cache validator groups and any other session-stable data (if present).