Skip to content

Commit

Permalink
Stop writing down usage at all versions (#15148)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse authored Nov 1, 2024
1 parent dd5371e commit 5a7a416
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion storage/aptosdb/src/db/include/aptosdb_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ impl AptosDB {
// Always put in state value index for now.
// TODO(grao): remove after APIs migrated off the DB to the indexer.
self.state_store.state_kv_db.enabled_sharding(),
skip_index_and_usage,
chunk.transaction_infos
.iter()
.rposition(|t| t.state_checkpoint_hash().is_some()),
Expand Down
1 change: 0 additions & 1 deletion storage/aptosdb/src/db/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pub(crate) fn update_store(
&ledger_batch,
&sharded_state_kv_batches,
/*put_state_value_indices=*/ enable_sharding,
/*skip_usage=*/ false,
/*last_checkpoint_index=*/ None,
)
.unwrap();
Expand Down
1 change: 0 additions & 1 deletion storage/aptosdb/src/pruner/state_merkle_pruner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ fn put_value_set(
&ledger_batch,
&sharded_state_kv_batches,
enable_sharding,
/*skip_usage=*/ false,
/*last_checkpoint_index=*/ None,
)
.unwrap();
Expand Down
16 changes: 3 additions & 13 deletions storage/aptosdb/src/state_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ impl StateStore {
None,
batch,
sharded_state_kv_batches,
/*skip_usage=*/ false,
None,
enable_sharding,
)?;
Expand All @@ -696,7 +695,6 @@ impl StateStore {
ledger_batch: &SchemaBatch,
sharded_state_kv_batches: &ShardedStateKvSchemaBatch,
enable_sharding: bool,
skip_usage: bool,
last_checkpoint_index: Option<usize>,
) -> Result<()> {
let _timer = OTHER_TIMERS_SECONDS
Expand All @@ -710,7 +708,6 @@ impl StateStore {
sharded_state_cache,
ledger_batch,
sharded_state_kv_batches,
skip_usage,
last_checkpoint_index,
enable_sharding,
)?;
Expand Down Expand Up @@ -786,7 +783,6 @@ impl StateStore {
sharded_state_cache: Option<&ShardedStateCache>,
batch: &SchemaBatch,
sharded_state_kv_batches: &ShardedStateKvSchemaBatch,
skip_usage: bool,
last_checkpoint_index: Option<usize>,
enable_sharding: bool,
) -> Result<()> {
Expand Down Expand Up @@ -947,16 +943,10 @@ impl StateStore {
(usage.items() as i64 + items_delta) as usize,
(usage.bytes() as i64 + bytes_delta) as usize,
);
let should_write_index_for_version =
(i == num_versions - 1) || Some(i) == last_checkpoint_index;
if !skip_usage || should_write_index_for_version {
if (i == num_versions - 1) || Some(i) == last_checkpoint_index {
let version = first_version + i as u64;
if should_write_index_for_version {
info!("Write usage at version {version}, {usage:?}, skip_usage: {skip_usage}.");
}
batch
.put::<VersionDataSchema>(&version, &usage.into())
.unwrap();
info!("Write usage at version {version}, {usage:?}.");
batch.put::<VersionDataSchema>(&version, &usage.into())?
}
}

Expand Down
1 change: 0 additions & 1 deletion storage/aptosdb/src/state_store/state_store_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ fn put_value_set(
&ledger_batch,
&sharded_state_kv_batches,
/*put_state_value_indices=*/ false,
/*skip_usage=*/ false,
/*last_checkpoint_index=*/ None,
)
.unwrap();
Expand Down

0 comments on commit 5a7a416

Please sign in to comment.