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(storage): use roaring bitmaps for history tables #5463

Merged
merged 28 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f4be9ea
feat(storage): use roaring bitmaps for history tables
shekhirin Nov 16, 2023
bad45bc
fix tests
shekhirin Nov 16, 2023
7f3a7b5
fix clippy
shekhirin Nov 16, 2023
4002bdc
update checkpoints on reth stage run
shekhirin Nov 16, 2023
b283b4e
deduplicate indices on insertion
shekhirin Nov 16, 2023
662da5c
Revert "deduplicate indices on insertion"
shekhirin Nov 16, 2023
1764a25
save one last checkpoint on stage run
shekhirin Nov 16, 2023
4c15a76
make tests compile
shekhirin Nov 17, 2023
fa793aa
introduce --checkpoints arg
shekhirin Nov 17, 2023
9a5a889
fix tests
shekhirin Nov 17, 2023
9c4d95a
Merge remote-tracking branch 'origin/main' into alexey/roaring-bitmaps
shekhirin Nov 17, 2023
444d49a
Merge remote-tracking branch 'origin/breaking-changes' into alexey/ro…
shekhirin Nov 17, 2023
9b1e39a
fix history_info
shekhirin Nov 18, 2023
8d247ec
clarify adjustment
shekhirin Nov 18, 2023
752c46e
fix prune test
shekhirin Nov 18, 2023
6e2d6d7
Merge remote-tracking branch 'origin/main' into alexey/roaring-bitmaps
shekhirin Nov 23, 2023
757b9ea
add roaring bitmaps vs elias-fano bench
shekhirin Nov 23, 2023
e8178e0
Merge remote-tracking branch 'origin/breaking-changes' into alexey/ro…
shekhirin Nov 23, 2023
b4b80d7
bump sucds
shekhirin Nov 23, 2023
73cabe7
fix test
shekhirin Nov 23, 2023
da47c23
comma
shekhirin Nov 23, 2023
46c7461
fix bench
shekhirin Nov 23, 2023
500aba9
no need for black_box inside the setup
shekhirin Nov 23, 2023
93ec8a4
Merge remote-tracking branch 'origin/breaking-changes' into alexey/ro…
shekhirin Jan 9, 2024
7812a4e
Merge remote-tracking branch 'origin/breaking-changes' into alexey/ro…
shekhirin Jan 9, 2024
4b1a924
fix clippy
shekhirin Jan 9, 2024
e716c34
remove sucds dep
shekhirin Jan 9, 2024
87b8cb1
more clippy fixes
shekhirin Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions bin/reth/src/commands/stage/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use reth_config::Config;
use reth_db::init_db;
use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
use reth_primitives::ChainSpec;
use reth_provider::{ProviderFactory, StageCheckpointReader};
use reth_provider::{ProviderFactory, StageCheckpointReader, StageCheckpointWriter};
use reth_stages::{
stages::{
AccountHashingStage, BodyStage, ExecutionStage, ExecutionStageThresholds,
IndexAccountHistoryStage, IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage,
StorageHashingStage, TransactionLookupStage,
},
ExecInput, Stage, StageExt, UnwindInput,
ExecInput, ExecOutput, Stage, StageExt, UnwindInput, UnwindOutput,
};
use std::{any::Any, net::SocketAddr, path::PathBuf, sync::Arc};
use tracing::*;
Expand Down Expand Up @@ -102,6 +102,10 @@ pub struct Command {
// e.g. query the DB size, or any table data.
#[arg(long, short)]
commit: bool,

/// Save stage checkpoints
#[arg(long)]
checkpoints: bool,
}

impl Command {
Expand Down Expand Up @@ -244,8 +248,12 @@ impl Command {

if !self.skip_unwind {
while unwind.checkpoint.block_number > self.from {
let unwind_output = unwind_stage.unwind(&provider_rw, unwind)?;
unwind.checkpoint = unwind_output.checkpoint;
let UnwindOutput { checkpoint } = unwind_stage.unwind(&provider_rw, unwind)?;
unwind.checkpoint = checkpoint;

if self.checkpoints {
provider_rw.save_stage_checkpoint(unwind_stage.id(), checkpoint)?;
}

if self.commit {
provider_rw.commit()?;
Expand All @@ -261,16 +269,19 @@ impl Command {

loop {
exec_stage.execute_ready(input).await?;
let output = exec_stage.execute(&provider_rw, input)?;
let ExecOutput { checkpoint, done } = exec_stage.execute(&provider_rw, input)?;

input.checkpoint = Some(output.checkpoint);
input.checkpoint = Some(checkpoint);

if self.checkpoints {
provider_rw.save_stage_checkpoint(exec_stage.id(), checkpoint)?;
}
if self.commit {
provider_rw.commit()?;
provider_rw = factory.provider_rw()?;
}

if output.done {
if done {
break
}
}
Expand Down
9 changes: 3 additions & 6 deletions crates/interfaces/src/test_utils/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,9 @@ pub fn random_eoa_account<R: Rng>(rng: &mut R) -> (Address, Account) {
}

/// Generate random Externally Owned Accounts
pub fn random_eoa_account_range<R: Rng>(
rng: &mut R,
acc_range: Range<u64>,
) -> Vec<(Address, Account)> {
let mut accounts = Vec::with_capacity(acc_range.end.saturating_sub(acc_range.start) as usize);
for _ in acc_range {
pub fn random_eoa_accounts<R: Rng>(rng: &mut R, accounts_num: usize) -> Vec<(Address, Account)> {
let mut accounts = Vec::with_capacity(accounts_num);
for _ in 0..accounts_num {
accounts.push(random_eoa_account(rng))
}
accounts
Expand Down
9 changes: 8 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ rayon.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2 = "0.10.7"
sucds = "~0.6"
tempfile.workspace = true
thiserror.workspace = true
zstd = { version = "0.12", features = ["experimental"] }
ahash.workspace = true
roaring = "0.10.2"

# `test-utils` feature
hash-db = { version = "~0.15", optional = true }
Expand Down Expand Up @@ -82,6 +82,9 @@ triehash = "0.8"
hash-db = "~0.15"
plain_hasher = "0.2"

sucds = "0.8.1"
anyhow = "1.0.75"

# necessary so we don't hit a "undeclared 'std'":
# https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198
criterion.workspace = true
Expand Down Expand Up @@ -122,3 +125,7 @@ harness = false
[[bench]]
name = "nibbles"
harness = false

[[bench]]
name = "integer_list"
harness = false
Loading
Loading