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

persistence softfork cache #4203

Merged
merged 4 commits into from
Nov 3, 2023
Merged

Conversation

zhangsoledad
Copy link
Member

@zhangsoledad zhangsoledad commented Oct 25, 2023

What problem does this PR solve?

In RFC0043 we introduced the signal mechanism to implement softfork-activation, for each softfork deployment its state needs to be accumulated statistics, the current implementation is to use a memory cache to store the state, resulting in each reboot, the state of the deployment needs to be regenerated. when in the case of large amounts of data, the reboot will be lagged for some time.

What is changed and how it works?

Introduces a persistent mmap cache so that the state doesn't need to be recalculated each time it is restarted

The persistence path is stored in DATA_DIR/softfork/<deployment>/<cache file> format.

image

after

image

Related changes

  • PR to update owner/repo:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Performance regression
  • Breaking backward compatibility

Release note

Title Only: Include only the PR title in the release note.

@zhangsoledad zhangsoledad requested a review from a team as a code owner October 25, 2023 09:43
@zhangsoledad zhangsoledad requested review from quake and removed request for a team October 25, 2023 09:43
@zhangsoledad zhangsoledad force-pushed the zhangsoledad/softfork-cache branch 3 times, most recently from b93adac to 9582cd4 Compare October 25, 2023 14:16
@eval-exec eval-exec added the t:enhancement Type: Feature, refactoring. label Oct 26, 2023
@eval-exec eval-exec self-requested a review October 26, 2023 02:03
pub use advanced_builders::{BlockBuilder, HeaderBuilder, TransactionBuilder};
pub use blockchain::DepType;
pub use extras::{BlockExt, EpochExt, EpochNumberWithFraction, TransactionInfo};
pub use fee_rate::FeeRate;
use once_cell::sync::OnceCell;
Copy link
Collaborator

@eval-exec eval-exec Nov 2, 2023

Choose a reason for hiding this comment

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

OnceCell have been merged into rust's std library: https://doc.rust-lang.org/std/cell/struct.OnceCell.html

Copy link
Member Author

Choose a reason for hiding this comment

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

The once_cell in std is still a bit different from the crate we're using now, and the equivalent would be https://doc.rust-lang.org/std/sync/struct.OnceLock.html, which we can decide to replace later.

@zhangsoledad zhangsoledad merged commit e27bcce into develop Nov 3, 2023
34 checks passed
@zhangsoledad zhangsoledad deleted the zhangsoledad/softfork-cache branch November 3, 2023 03:46
@doitian doitian mentioned this pull request Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:enhancement Type: Feature, refactoring.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants