-
Notifications
You must be signed in to change notification settings - Fork 2.4k
perf(db): do not heap-allocate the stage key per query #18284
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1642,7 +1642,11 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> BlockBodyIndicesProvider | |
|
|
||
| impl<TX: DbTx, N: NodeTypes> StageCheckpointReader for DatabaseProvider<TX, N> { | ||
| fn get_stage_checkpoint(&self, id: StageId) -> ProviderResult<Option<StageCheckpoint>> { | ||
| Ok(self.tx.get::<tables::StageCheckpoints>(id.to_string())?) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, isn't this the same as then we dont even need the map EDIT: nvm we need the vec
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's unfortunate to use heap types for table keys and their encoding, but the overhead also isn't big enough to migrate. We live with it for another day! |
||
| Ok(if let Some(encoded) = id.get_pre_encoded() { | ||
| self.tx.get_by_encoded_key::<tables::StageCheckpoints>(encoded)? | ||
| } else { | ||
| self.tx.get::<tables::StageCheckpoints>(id.to_string())? | ||
| }) | ||
| } | ||
|
|
||
| /// Get stage checkpoint progress. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 heap-allocated per database query, even when the hottest queries have "constant" stage ids like "Finish", which should be (pre)allocated only once.
This is also our initial interested hot path,
get_pre_encodedcan be applied to more places -- anywhere thatgets from checkpoint tables.