-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
// encode them, and write them to the DB. | ||
// | ||
// TODO: parallelize | ||
fn to_rlp(self, db: &mut HashDB, storage: &mut NodeStorage) -> Bytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning ElasticArray1024
here would save lots of memory allocations
stream.drain()
So this implementation has a flaw where it never deletes nodes from the DB and may re-insert nodes that already exist in it. |
gives ~5% speedup importing the first 250k blocks for me |
coverage decreased? |
Some((new, changed)) => { | ||
children[idx] = Some(new.into()); | ||
let branch = Node::Branch(children, value); | ||
if changed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else {
line is a bit wasteful for these trivial ternary-like conditionals. typically use match
instead.
a few points where style could better follow the "house rules". otherwise looks like quality code. didn't do a deep inspection of the logic, which is likely unnecessary assuming all tests pass and unlikely to uncover any deep-seated bugs. probably good to get another pair of eyes over it though. |
coverage decreased as a percentage because the code itself is larger. i have also added an |
Changes Unknown when pulling 9c36b5f on rphmeier:insertion_trie into * on ethcore:master*. |
travis failed on an unrelated network test, but not before all trie json tests and util tests passed. |
This is an optimization PR introducing an alternative implementation of TrieDBMut.
While the old
TrieDBMut
recalculates all affected node RLPs and commits to the DB at the end of each insert or remove operation, the new one does only when it is dropped orroot
orcommit
is explicitly called.