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

feat(gas_price_service): improve performance of SharedGasPriceAlgo by replacing underlying RwLock with SeqLock #2528

Closed

Conversation

rymnc
Copy link
Member

@rymnc rymnc commented Jan 2, 2025

Warning

Merging blocked by #2524, please review that first :)

Linked Issues/PRs

  • none

Description

The SharedGasPriceAlgo implementations, SharedV1Algorithm, SharedV0Algorithm make use of an Arc<parking_lot::Mutex<A>>, however, since the internal type used is relatively small, we can make use of SeqLock introduced in #2524, as it meets the requirements of using it, i.e -

  1. Small type cheap to copy,
  2. Occasional writes, frequent reads

you might wonder that we might have "torn reads" but as long as the data fits in a single cache line we are safe here, and since the size of AlgorithmV1 is 40 bytes (padding incl), it fits in a 64-byte cache-line, and hence is safe to use with SeqLock

fetching the gas price is a very frequent operation, and although it might be cached by higher layers, we benefit from the SeqLock, as presented in the following benchmark result:

image

the baseline for the benchmark was generated using this branch: chore/baseline-shared-gas-price-algo-bench

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 force-pushed the test/seqlock-for-gas-price branch from 8150e07 to e659c05 Compare January 2, 2025 14:52
@rymnc rymnc self-assigned this Jan 2, 2025
@rymnc rymnc changed the title test: seqlock for gas price service? feat(gas_price_service): improve performance of SharedGasPriceAlgo by replacing underlying RwLock with SeqLock Jan 2, 2025
@rymnc rymnc force-pushed the test/seqlock-for-gas-price branch from 572f2ef to 21014f6 Compare January 2, 2025 15:00
@rymnc rymnc force-pushed the test/seqlock-for-gas-price branch from a3010ea to 18cb982 Compare January 2, 2025 15:27
@rymnc
Copy link
Member Author

rymnc commented Jan 10, 2025

this should not have been labelled for release

@rymnc rymnc removed the release label Jan 10, 2025
@rymnc
Copy link
Member Author

rymnc commented Jan 11, 2025

closing as not planned to integrate :)

@rymnc rymnc closed this Jan 11, 2025
@rymnc rymnc deleted the test/seqlock-for-gas-price branch January 11, 2025 09:17
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.

2 participants