forked from aserebryakov/trie-rs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Refactor the
Trie
and TrieNode
structs to replace the 2 vec…
…tors used to store values and trie node, by the root node of the trie. The values are now directly stored in the TrieNode (instead of having integers to get values from an array), and the Trie only contains 1 field: the root node of the trie. This reduces amount of effective line of code from 127 to 97. This seems to have improved performance in some cases (benchmark has been run twice to make sure those numbers are somewhat reproducible): * -30% on prefix/postfix matches (was ~350µs, is now ~230µs) * Sometimes -98% on mismatch (was ~70µs, is now ~1µs sometimes) * Interestingly we see a regression +20% for massive_match, even if match see an improvement of -33% Full Criterion benchmark results (the diff is with the previous implementation with vectors): ``` trie_match time: [6.5473 ns 6.7279 ns 6.9287 ns] change: [-34.375% -32.939% -31.369%] (p = 0.00 < 0.05) Performance has improved. Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) high mild trie_mismatch time: [3.6109 ns 3.6956 ns 3.7926 ns] change: [-46.306% -44.989% -43.610%] (p = 0.00 < 0.05) Performance has improved. Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) high mild trie_massive_match time: [154.76 µs 156.44 µs 158.59 µs] change: [+18.768% +21.621% +24.627%] (p = 0.00 < 0.05) Performance has regressed. Found 5 outliers among 100 measurements (5.00%) 5 (5.00%) high mild trie_massive_mismatch_on_0 time: [25.287 µs 25.821 µs 26.399 µs] change: [-14.458% -11.912% -9.2597%] (p = 0.00 < 0.05) Performance has improved. Found 5 outliers among 100 measurements (5.00%) 5 (5.00%) high mild trie_massive_mismatch_on_1 time: [1.1365 µs 1.1609 µs 1.1929 µs] change: [-98.281% -98.262% -98.240%] (p = 0.00 < 0.05) Performance has improved. Found 7 outliers among 100 measurements (7.00%) 4 (4.00%) high mild 3 (3.00%) high severe trie_massive_mismatch_on_2 time: [24.619 µs 24.728 µs 24.879 µs] change: [-3.7176% -2.9119% -1.7259%] (p = 0.00 < 0.05) Performance has improved. Found 6 outliers among 100 measurements (6.00%) 3 (3.00%) high mild 3 (3.00%) high severe trie_massive_mismatch_on_3 time: [22.300 µs 22.377 µs 22.473 µs] change: [-12.754% -12.221% -11.670%] (p = 0.00 < 0.05) Performance has improved. Found 5 outliers among 100 measurements (5.00%) 4 (4.00%) high mild 1 (1.00%) high severe trie_prefixes_match time: [240.67 µs 247.70 µs 255.57 µs] change: [-30.363% -28.485% -26.708%] (p = 0.00 < 0.05) Performance has improved. Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) high mild trie_postfixes_match time: [227.52 µs 233.84 µs 241.09 µs] change: [-28.965% -26.333% -23.562%] (p = 0.00 < 0.05) Performance has improved. Found 7 outliers among 100 measurements (7.00%) 4 (4.00%) high mild 3 (3.00%) high severe trie_prefix_longest_match time: [133.98 µs 137.34 µs 141.30 µs] change: [-41.923% -39.851% -37.699%] (p = 0.00 < 0.05) Performance has improved. Found 20 outliers among 100 measurements (20.00%) 5 (5.00%) high mild 15 (15.00%) high severe trie_massive_prefixes_match time: [228.73 µs 234.37 µs 241.08 µs] change: [-31.061% -29.485% -27.961%] (p = 0.00 < 0.05) Performance has improved. Found 17 outliers among 100 measurements (17.00%) 6 (6.00%) high mild 11 (11.00%) high severe trie_massive_longest_prefixes_match time: [157.31 µs 160.18 µs 163.82 µs] change: [-28.283% -25.535% -22.555%] (p = 0.00 < 0.05) Performance has improved. Found 11 outliers among 100 measurements (11.00%) 7 (7.00%) high mild 4 (4.00%) high severe trie_massive_postfixes_match time: [226.97 µs 231.64 µs 237.56 µs] change: [-21.204% -18.930% -16.464%] (p = 0.00 < 0.05) Performance has improved. Found 5 outliers among 100 measurements (5.00%) 3 (3.00%) high mild 2 (2.00%) high severe ``` BREAKING CHANGE: the find prefixes/postfixes functions now returns references to value instead of cloned values
- Loading branch information
Showing
5 changed files
with
123 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chain_width = 70 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.