Skip to content

Replace ElasticArray with SmallVec#46

Merged
cheme merged 4 commits into
masterfrom
dp/chore/replace-elastic-array-with-smallvec
Dec 17, 2019
Merged

Replace ElasticArray with SmallVec#46
cheme merged 4 commits into
masterfrom
dp/chore/replace-elastic-array-with-smallvec

Conversation

@dvdplm
Copy link
Copy Markdown
Contributor

@dvdplm dvdplm commented Dec 12, 2019

The elastic-array crate is a fine piece of software but it'd be good to prefer crates that are commonly used in the ecosystem and likely to be well maintained. smallvec is at v1.0 and generally well-regarded.

Unfortunately as DBValue is part of the public API of trie-db, this is a breaking change so changing this implies annoying busy-work in consuming code.

@dvdplm dvdplm self-assigned this Dec 12, 2019
@dvdplm dvdplm marked this pull request as ready for review December 12, 2019 15:34
@dvdplm dvdplm requested review from cheme and debris December 12, 2019 15:34
dvdplm added a commit to openethereum/parity-ethereum that referenced this pull request Dec 12, 2019
The elastic-array crate is a fine piece of software but it'd be good to prefer crates that are commonly used in the ecosystem and likely to be well maintained. smallvec is at v1.0 and generally well-regarded.

Related PRs:

	- [parity-common #282](paritytech/parity-common#282)
	– [trie-db #46](paritytech/trie#46)
Copy link
Copy Markdown
Contributor

@jimpo jimpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of this switch. Though maybe it's also worth benchmarking this against regular Vec.

Comment thread trie-db/src/nibble/mod.rs Outdated
Copy link
Copy Markdown
Contributor

@cheme cheme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me. On the other hand I got a small surprise when running a few of the bench, especially 'trie_mut_build_a', where perf decrease a bit. I observe that this bench is the one with bigger content stored, and testing with this branch (uses 'Vec' for 'DBValue'), I got my performance back and improvment on 'trie_mut_b'.
I think it is worth considering making DBValue Vec (in many case it ends up being converted to Vec).

@dvdplm
Copy link
Copy Markdown
Contributor Author

dvdplm commented Dec 15, 2019

I think it is worth considering making DBValue Vec (in many case it ends up being converted to Vec).

I went ahead and implemented this in b18e2db and the terrible perf regression seems to have gone away. A bit unsure of how big the impact is on the substrate side though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants