From 7b0e4af078eac3b63147fefaf90674e780373d5f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 18 Jan 2016 14:44:06 +0100 Subject: [PATCH] Compact state DB finished. Closes #172 --- src/client.rs | 6 +++--- src/sync/chain.rs | 2 +- util/src/journaldb.rs | 1 + util/src/overlaydb.rs | 8 ++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client.rs b/src/client.rs index fe3eee242..cb1f4672d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -117,7 +117,7 @@ impl Client { let mut opts = Options::new(); opts.create_if_missing(true); opts.set_max_open_files(256); - opts.set_use_fsync(false); + /*opts.set_use_fsync(false); opts.set_bytes_per_sync(8388608); opts.set_disable_data_sync(false); opts.set_block_cache_size_mb(1024); @@ -132,7 +132,7 @@ impl Client { opts.set_max_background_compactions(4); opts.set_max_background_flushes(4); opts.set_filter_deletes(false); - opts.set_disable_auto_compactions(true); + opts.set_disable_auto_compactions(false);*/ let mut state_path = path.to_path_buf(); state_path.push("state"); @@ -207,7 +207,7 @@ impl Client { return; } } - info!(target: "client", "Imported #{} ({})", header.number(), header.hash()); + debug!(target: "client", "Imported #{} ({})", header.number(), header.hash()); } } diff --git a/src/sync/chain.rs b/src/sync/chain.rs index 43f5968f4..40dbc6c9c 100644 --- a/src/sync/chain.rs +++ b/src/sync/chain.rs @@ -471,7 +471,7 @@ impl ChainSync { pub fn on_peer_aborting(&mut self, io: &mut SyncIo, peer: PeerId) { trace!(target: "sync", "== Disconnecting {}", peer); if self.peers.contains_key(&peer) { - info!(target: "sync", "Disconneced {}:{}", peer, io.peer_info(peer)); + info!(target: "sync", "Disconnected {}:{}", peer, io.peer_info(peer)); self.clear_peer_download(peer); self.peers.remove(&peer); self.continue_sync(io); diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index 8dd49cda1..803c0a8c3 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -100,6 +100,7 @@ impl JournalDB { self.forward.remove(i); } try!(self.backing.delete(&last)); + info!("JournalDB: delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, to_remove.len()); index += 1; } } diff --git a/util/src/overlaydb.rs b/util/src/overlaydb.rs index 3c2286657..1d369af96 100644 --- a/util/src/overlaydb.rs +++ b/util/src/overlaydb.rs @@ -71,6 +71,7 @@ impl OverlayDB { /// ``` pub fn commit(&mut self) -> Result { let mut ret = 0u32; + let mut deletes = 0usize; for i in self.overlay.drain().into_iter() { let (key, (value, rc)) = i; if rc != 0 { @@ -81,7 +82,7 @@ impl OverlayDB { if total_rc < 0 { return Err(From::from(BaseDataError::NegativelyReferencedHash)); } - self.put_payload(&key, (back_value, total_rc as u32)); + deletes += if self.put_payload(&key, (back_value, total_rc as u32)) {1} else {0}; } None => { if rc < 0 { @@ -93,6 +94,7 @@ impl OverlayDB { ret += 1; } } + info!("OverlayDB::commit() deleted {} nodes", deletes); Ok(ret) } @@ -130,14 +132,16 @@ impl OverlayDB { } /// Get the refs and value of the given key. - fn put_payload(&self, key: &H256, payload: (Bytes, u32)) { + fn put_payload(&self, key: &H256, payload: (Bytes, u32)) -> bool { if payload.1 > 0 { let mut s = RlpStream::new_list(2); s.append(&payload.1); s.append(&payload.0); self.backing.put(&key.bytes(), &s.out()).expect("Low-level database error. Some issue with your hard disk?"); + false } else { self.backing.delete(&key.bytes()).expect("Low-level database error. Some issue with your hard disk?"); + true } }