Skip to content
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

chore(gas_price_service): refactor usage of async_trait impls to improve performance #2632

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

rymnc
Copy link
Member

@rymnc rymnc commented Jan 25, 2025

Linked Issues/PRs

  • none

Description

reduces heap allocs by removing usage of async_trait for small types being passed around in gas price service adapters. should improve performance because no Pin<Box<Future>>> for small values which can be efficiently allocated on the stack instead.

microbenchmarks yield performance increase of $$\approx 82.57\% %$$ for get_l2_block

makes GasPriceProvider sync

breaking:
consumers of the L2BlockSource and GasPriceProvider traits, which is most likely just us at this point

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@rymnc rymnc self-assigned this Jan 25, 2025
@rymnc rymnc marked this pull request as ready for review January 25, 2025 21:39
xgreenx
xgreenx previously approved these changes Jan 25, 2025
@@ -203,7 +203,6 @@ mod tests {
l2_block: mpsc::Receiver<BlockInfo>,
}

#[async_trait::async_trait]
impl L2BlockSource for FakeL2BlockSource {
async fn get_l2_block(&mut self) -> GasPriceResult<BlockInfo> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the async still work here? I'm not sure if it desugars to the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'm playing around with it in playground. Works for me.

@rymnc rymnc requested a review from xgreenx January 25, 2025 22:11
@rymnc rymnc enabled auto-merge (squash) January 25, 2025 22:12
@rymnc rymnc merged commit 902f772 into master Jan 27, 2025
32 checks passed
@rymnc rymnc deleted the refactor/gas-price-service branch January 27, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants