Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Bump memory-db lib to 0.24.1 and add shrink_to_fit #11760 #11827

Merged
merged 2 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion ethcore/account-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.7"
log = "0.4"
lru-cache = "0.1.2"
memory-db = "0.21.1"
memory-db = "0.24.1"
parity-bytes = "0.1.0"
parity-util-mem = "0.7"
parking_lot = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ethcore-blockchain = { path = "../blockchain" }
ethereum-types = "0.9.2"
executive-state = { path = "../executive-state" }
machine = { path = "../machine" }
memory-db = "0.21.1"
memory-db = "0.24.1"
trie-db = "0.21.0"
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
ethcore-network = { path = "../../util/network" }
Expand Down
13 changes: 7 additions & 6 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ impl Client {
// If a snapshot is under way, no pruning happens and memory consumption is allowed to
// increase above the memory target until the snapshot has finished.
loop {
let needs_pruning = state_db.journal_db().journal_size() >= self.config.history_mem;
let journal_size = state_db.journal_db().journal_size();
let needs_pruning = journal_size >= self.config.history_mem;

if !needs_pruning {
break
Expand All @@ -983,12 +984,12 @@ impl Client {
// Note: journal_db().mem_used() can be used for a more accurate memory
// consumption measurement but it can be expensive so sticking with the
// faster `journal_size()` instead.
trace!(target: "pruning", "Pruning is paused at era {} (snapshot under way); earliest era={}, latest era={}, journal_size={} – Not pruning.",
freeze_at, earliest_era, latest_era, state_db.journal_db().journal_size());
info!(target: "pruning", "Pruning is paused at era {} (snapshot under way); earliest era={}, latest era={}, journal_size={} – Not pruning.",
freeze_at, earliest_era, latest_era, journal_size);
break;
}
trace!(target: "pruning", "Pruning state for ancient era #{}; latest era={}, journal_size={}",
earliest_era, latest_era, state_db.journal_db().journal_size());
info!(target: "pruning", "Pruning state for ancient era #{}; latest era={}, journal_size={}",
earliest_era, latest_era, journal_size);
match chain.block_hash(earliest_era) {
Some(ancient_hash) => {
let mut batch = DBTransaction::new();
Expand Down Expand Up @@ -2611,7 +2612,7 @@ impl SnapshotClient for Client {
self.snapshotting_at.store(actual_block_nr, Ordering::SeqCst);
{
scopeguard::defer! {{
trace!(target: "snapshot", "Re-enabling pruning.");
info!(target: "snapshot", "Re-enabling pruning.");
self.snapshotting_at.store(0, Ordering::SeqCst)
}};
let chunker = snapshot::chunker(self.engine.snapshot_mode()).ok_or_else(|| SnapshotError::SnapshotsUnsupported)?;
Expand Down
2 changes: 1 addition & 1 deletion util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parity-util-mem = "0.7"
keccak-hasher = { path = "../keccak-hasher" }
kvdb = "0.7"
log = "0.4"
memory-db = "0.21.1"
memory-db = "0.24.1"
parking_lot = "0.10.0"
fastmap = { path = "../../util/fastmap" }
rlp = "0.4.5"
Expand Down
4 changes: 4 additions & 0 deletions util/journaldb/src/overlayrecentdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ impl JournalDB for OverlayRecentDB {
journal_overlay.earliest_era = Some(end_era + 1);
}

//garbage collection on MemoryDB and journal HashMaps;
journal_overlay.backing_overlay.shrink_to_fit();
journal_overlay.journal.shrink_to_fit();

Ok(ops as u32)
}

Expand Down
2 changes: 1 addition & 1 deletion util/patricia-trie-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ethereum-types = "0.9.2"
elastic-array = "0.10"

[dev-dependencies]
memory-db = "0.21.1"
memory-db = "0.24.1"
keccak-hash = "0.5.0"
journaldb = { path = "../journaldb" }
criterion = "0.3"
Expand Down