Skip to content

Comments

Improve performance tuning slice capacity#23

Merged
derekparker merged 4 commits intoderekparker:masterfrom
jsign:fastallocs
Aug 5, 2019
Merged

Improve performance tuning slice capacity#23
derekparker merged 4 commits intoderekparker:masterfrom
jsign:fastallocs

Conversation

@jsign
Copy link
Contributor

@jsign jsign commented Aug 5, 2019

I worked on top of #17.

  • deleted unused function: Just to cleanup agreed on @derekparker review.
  • created a count of leaves per node: this allows to create the keys slice in collect with the correct capacity to avoid allocations while appending.
  • in collect the nodes capacity is set to a lower-bound which save more allocations.

Here's the benchmark comparison to master now:

benchmark                   old ns/op     new ns/op     delta
BenchmarkTieKeys-8          5098          2385          -53.22%
BenchmarkPrefixSearch-8     393791        118249        -69.97%
BenchmarkFuzzySearch-8      6001483       4151116       -30.83%

benchmark                   old allocs     new allocs     delta
BenchmarkTieKeys-8          56             3              -94.64%
BenchmarkPrefixSearch-8     5548           3              -99.95%
BenchmarkFuzzySearch-8      47089          8009           -82.99%

benchmark                   old bytes     new bytes     delta
BenchmarkTieKeys-8          840           256           -69.52%
BenchmarkPrefixSearch-8     71628         13120         -81.68%
BenchmarkFuzzySearch-8      793796        476874        -39.92%

@derekparker derekparker merged commit 4e1a77f into derekparker:master Aug 5, 2019
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.

3 participants