-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure find
performs splay
#1017
Conversation
Added splay operation after locating the node in the Find function. Simplified IndexOf() function by utilizing the splay operation, reducing the need for additional traversal logic and ensuring efficient access. By incorporating splay in both functions, the tree maintains its self-balancing property and ensures amortized O(log n) time complexity for future operations.
WalkthroughThe changes in the pull request involve modifications to the Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1017 +/- ##
==========================================
+ Coverage 48.68% 48.76% +0.08%
==========================================
Files 79 79
Lines 11351 11344 -7
==========================================
+ Hits 5526 5532 +6
+ Misses 5276 5269 -7
+ Partials 549 543 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ndexOf()" This reverts commit 59e27ae.
The benchmarks include three tests: a stress test that randomly performs insert, delete, find, and range delete operations; a skewed tree test with 1000 random accesses; and a text editing benchmark based on the editing-trace.json file.
Added splay operation after locating the node in the Find function. Simplified IndexOf() function by utilizing the splay operation, reducing the need for additional traversal logic and ensuring efficient access. By incorporating splay in both functions, the tree maintains its self-balancing property and ensures amortized O(log n) time complexity for future operations.
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.
Go Benchmark
Benchmark suite | Current: 51b92b1 | Previous: 59e27ae | Ratio |
---|---|---|---|
BenchmarkDocument/constructor_test |
1516 ns/op 1337 B/op 24 allocs/op |
1534 ns/op 1337 B/op 24 allocs/op |
0.99 |
BenchmarkDocument/constructor_test - ns/op |
1516 ns/op |
1534 ns/op |
0.99 |
BenchmarkDocument/constructor_test - B/op |
1337 B/op |
1337 B/op |
1 |
BenchmarkDocument/constructor_test - allocs/op |
24 allocs/op |
24 allocs/op |
1 |
BenchmarkDocument/status_test |
970 ns/op 1305 B/op 22 allocs/op |
976.4 ns/op 1305 B/op 22 allocs/op |
0.99 |
BenchmarkDocument/status_test - ns/op |
970 ns/op |
976.4 ns/op |
0.99 |
BenchmarkDocument/status_test - B/op |
1305 B/op |
1305 B/op |
1 |
BenchmarkDocument/status_test - allocs/op |
22 allocs/op |
22 allocs/op |
1 |
BenchmarkDocument/equals_test |
9229 ns/op 7273 B/op 132 allocs/op |
7718 ns/op 7273 B/op 132 allocs/op |
1.20 |
BenchmarkDocument/equals_test - ns/op |
9229 ns/op |
7718 ns/op |
1.20 |
BenchmarkDocument/equals_test - B/op |
7273 B/op |
7273 B/op |
1 |
BenchmarkDocument/equals_test - allocs/op |
132 allocs/op |
132 allocs/op |
1 |
BenchmarkDocument/nested_update_test |
17641 ns/op 12139 B/op 262 allocs/op |
17978 ns/op 12139 B/op 262 allocs/op |
0.98 |
BenchmarkDocument/nested_update_test - ns/op |
17641 ns/op |
17978 ns/op |
0.98 |
BenchmarkDocument/nested_update_test - B/op |
12139 B/op |
12139 B/op |
1 |
BenchmarkDocument/nested_update_test - allocs/op |
262 allocs/op |
262 allocs/op |
1 |
BenchmarkDocument/delete_test |
23570 ns/op 15364 B/op 341 allocs/op |
22943 ns/op 15364 B/op 341 allocs/op |
1.03 |
BenchmarkDocument/delete_test - ns/op |
23570 ns/op |
22943 ns/op |
1.03 |
BenchmarkDocument/delete_test - B/op |
15364 B/op |
15364 B/op |
1 |
BenchmarkDocument/delete_test - allocs/op |
341 allocs/op |
341 allocs/op |
1 |
BenchmarkDocument/object_test |
8807 ns/op 6817 B/op 120 allocs/op |
8767 ns/op 6817 B/op 120 allocs/op |
1.00 |
BenchmarkDocument/object_test - ns/op |
8807 ns/op |
8767 ns/op |
1.00 |
BenchmarkDocument/object_test - B/op |
6817 B/op |
6817 B/op |
1 |
BenchmarkDocument/object_test - allocs/op |
120 allocs/op |
120 allocs/op |
1 |
BenchmarkDocument/array_test |
30744 ns/op 11947 B/op 276 allocs/op |
31278 ns/op 11947 B/op 276 allocs/op |
0.98 |
BenchmarkDocument/array_test - ns/op |
30744 ns/op |
31278 ns/op |
0.98 |
BenchmarkDocument/array_test - B/op |
11947 B/op |
11947 B/op |
1 |
BenchmarkDocument/array_test - allocs/op |
276 allocs/op |
276 allocs/op |
1 |
BenchmarkDocument/text_test |
32242 ns/op 14780 B/op 486 allocs/op |
33696 ns/op 14780 B/op 486 allocs/op |
0.96 |
BenchmarkDocument/text_test - ns/op |
32242 ns/op |
33696 ns/op |
0.96 |
BenchmarkDocument/text_test - B/op |
14780 B/op |
14780 B/op |
1 |
BenchmarkDocument/text_test - allocs/op |
486 allocs/op |
486 allocs/op |
1 |
BenchmarkDocument/text_composition_test |
31156 ns/op 18463 B/op 502 allocs/op |
30520 ns/op 18460 B/op 502 allocs/op |
1.02 |
BenchmarkDocument/text_composition_test - ns/op |
31156 ns/op |
30520 ns/op |
1.02 |
BenchmarkDocument/text_composition_test - B/op |
18463 B/op |
18460 B/op |
1.00 |
BenchmarkDocument/text_composition_test - allocs/op |
502 allocs/op |
502 allocs/op |
1 |
BenchmarkDocument/rich_text_test |
86137 ns/op 38709 B/op 1165 allocs/op |
84150 ns/op 38709 B/op 1165 allocs/op |
1.02 |
BenchmarkDocument/rich_text_test - ns/op |
86137 ns/op |
84150 ns/op |
1.02 |
BenchmarkDocument/rich_text_test - B/op |
38709 B/op |
38709 B/op |
1 |
BenchmarkDocument/rich_text_test - allocs/op |
1165 allocs/op |
1165 allocs/op |
1 |
BenchmarkDocument/counter_test |
18273 ns/op 10722 B/op 244 allocs/op |
17734 ns/op 10722 B/op 244 allocs/op |
1.03 |
BenchmarkDocument/counter_test - ns/op |
18273 ns/op |
17734 ns/op |
1.03 |
BenchmarkDocument/counter_test - B/op |
10722 B/op |
10722 B/op |
1 |
BenchmarkDocument/counter_test - allocs/op |
244 allocs/op |
244 allocs/op |
1 |
BenchmarkDocument/text_edit_gc_100 |
1354334 ns/op 871967 B/op 17275 allocs/op |
1327121 ns/op 872029 B/op 17276 allocs/op |
1.02 |
BenchmarkDocument/text_edit_gc_100 - ns/op |
1354334 ns/op |
1327121 ns/op |
1.02 |
BenchmarkDocument/text_edit_gc_100 - B/op |
871967 B/op |
872029 B/op |
1.00 |
BenchmarkDocument/text_edit_gc_100 - allocs/op |
17275 allocs/op |
17276 allocs/op |
1.00 |
BenchmarkDocument/text_edit_gc_1000 |
52635552 ns/op 50546487 B/op 186737 allocs/op |
51591480 ns/op 50545506 B/op 186732 allocs/op |
1.02 |
BenchmarkDocument/text_edit_gc_1000 - ns/op |
52635552 ns/op |
51591480 ns/op |
1.02 |
BenchmarkDocument/text_edit_gc_1000 - B/op |
50546487 B/op |
50545506 B/op |
1.00 |
BenchmarkDocument/text_edit_gc_1000 - allocs/op |
186737 allocs/op |
186732 allocs/op |
1.00 |
BenchmarkDocument/text_split_gc_100 |
2008988 ns/op 1588568 B/op 15945 allocs/op |
1961244 ns/op 1588511 B/op 15944 allocs/op |
1.02 |
BenchmarkDocument/text_split_gc_100 - ns/op |
2008988 ns/op |
1961244 ns/op |
1.02 |
BenchmarkDocument/text_split_gc_100 - B/op |
1588568 B/op |
1588511 B/op |
1.00 |
BenchmarkDocument/text_split_gc_100 - allocs/op |
15945 allocs/op |
15944 allocs/op |
1.00 |
BenchmarkDocument/text_split_gc_1000 |
122209248 ns/op 141482697 B/op 186154 allocs/op |
119474522 ns/op 141481867 B/op 186146 allocs/op |
1.02 |
BenchmarkDocument/text_split_gc_1000 - ns/op |
122209248 ns/op |
119474522 ns/op |
1.02 |
BenchmarkDocument/text_split_gc_1000 - B/op |
141482697 B/op |
141481867 B/op |
1.00 |
BenchmarkDocument/text_split_gc_1000 - allocs/op |
186154 allocs/op |
186146 allocs/op |
1.00 |
BenchmarkDocument/text_delete_all_10000 |
19535743 ns/op 10212590 B/op 55681 allocs/op |
18103436 ns/op 10212763 B/op 55679 allocs/op |
1.08 |
BenchmarkDocument/text_delete_all_10000 - ns/op |
19535743 ns/op |
18103436 ns/op |
1.08 |
BenchmarkDocument/text_delete_all_10000 - B/op |
10212590 B/op |
10212763 B/op |
1.00 |
BenchmarkDocument/text_delete_all_10000 - allocs/op |
55681 allocs/op |
55679 allocs/op |
1.00 |
BenchmarkDocument/text_delete_all_100000 |
368620091 ns/op 143034928 B/op 561706 allocs/op |
309423623 ns/op 142984224 B/op 561718 allocs/op |
1.19 |
BenchmarkDocument/text_delete_all_100000 - ns/op |
368620091 ns/op |
309423623 ns/op |
1.19 |
BenchmarkDocument/text_delete_all_100000 - B/op |
143034928 B/op |
142984224 B/op |
1.00 |
BenchmarkDocument/text_delete_all_100000 - allocs/op |
561706 allocs/op |
561718 allocs/op |
1.00 |
BenchmarkDocument/text_100 |
234009 ns/op 120234 B/op 5180 allocs/op |
217331 ns/op 120235 B/op 5180 allocs/op |
1.08 |
BenchmarkDocument/text_100 - ns/op |
234009 ns/op |
217331 ns/op |
1.08 |
BenchmarkDocument/text_100 - B/op |
120234 B/op |
120235 B/op |
1.00 |
BenchmarkDocument/text_100 - allocs/op |
5180 allocs/op |
5180 allocs/op |
1 |
BenchmarkDocument/text_1000 |
2533892 ns/op 1171026 B/op 51084 allocs/op |
2381179 ns/op 1171021 B/op 51084 allocs/op |
1.06 |
BenchmarkDocument/text_1000 - ns/op |
2533892 ns/op |
2381179 ns/op |
1.06 |
BenchmarkDocument/text_1000 - B/op |
1171026 B/op |
1171021 B/op |
1.00 |
BenchmarkDocument/text_1000 - allocs/op |
51084 allocs/op |
51084 allocs/op |
1 |
BenchmarkDocument/array_1000 |
1334380 ns/op 1091405 B/op 11832 allocs/op |
1223964 ns/op 1091322 B/op 11831 allocs/op |
1.09 |
BenchmarkDocument/array_1000 - ns/op |
1334380 ns/op |
1223964 ns/op |
1.09 |
BenchmarkDocument/array_1000 - B/op |
1091405 B/op |
1091322 B/op |
1.00 |
BenchmarkDocument/array_1000 - allocs/op |
11832 allocs/op |
11831 allocs/op |
1.00 |
BenchmarkDocument/array_10000 |
13878256 ns/op 9799310 B/op 120294 allocs/op |
13249930 ns/op 9799757 B/op 120296 allocs/op |
1.05 |
BenchmarkDocument/array_10000 - ns/op |
13878256 ns/op |
13249930 ns/op |
1.05 |
BenchmarkDocument/array_10000 - B/op |
9799310 B/op |
9799757 B/op |
1.00 |
BenchmarkDocument/array_10000 - allocs/op |
120294 allocs/op |
120296 allocs/op |
1.00 |
BenchmarkDocument/array_gc_100 |
159537 ns/op 132719 B/op 1260 allocs/op |
149614 ns/op 132729 B/op 1261 allocs/op |
1.07 |
BenchmarkDocument/array_gc_100 - ns/op |
159537 ns/op |
149614 ns/op |
1.07 |
BenchmarkDocument/array_gc_100 - B/op |
132719 B/op |
132729 B/op |
1.00 |
BenchmarkDocument/array_gc_100 - allocs/op |
1260 allocs/op |
1261 allocs/op |
1.00 |
BenchmarkDocument/array_gc_1000 |
1525856 ns/op 1159100 B/op 12876 allocs/op |
1403598 ns/op 1159209 B/op 12877 allocs/op |
1.09 |
BenchmarkDocument/array_gc_1000 - ns/op |
1525856 ns/op |
1403598 ns/op |
1.09 |
BenchmarkDocument/array_gc_1000 - B/op |
1159100 B/op |
1159209 B/op |
1.00 |
BenchmarkDocument/array_gc_1000 - allocs/op |
12876 allocs/op |
12877 allocs/op |
1.00 |
BenchmarkDocument/counter_1000 |
221011 ns/op 193081 B/op 5771 allocs/op |
201502 ns/op 193081 B/op 5771 allocs/op |
1.10 |
BenchmarkDocument/counter_1000 - ns/op |
221011 ns/op |
201502 ns/op |
1.10 |
BenchmarkDocument/counter_1000 - B/op |
193081 B/op |
193081 B/op |
1 |
BenchmarkDocument/counter_1000 - allocs/op |
5771 allocs/op |
5771 allocs/op |
1 |
BenchmarkDocument/counter_10000 |
2361681 ns/op 2087998 B/op 59778 allocs/op |
2229978 ns/op 2087996 B/op 59778 allocs/op |
1.06 |
BenchmarkDocument/counter_10000 - ns/op |
2361681 ns/op |
2229978 ns/op |
1.06 |
BenchmarkDocument/counter_10000 - B/op |
2087998 B/op |
2087996 B/op |
1.00 |
BenchmarkDocument/counter_10000 - allocs/op |
59778 allocs/op |
59778 allocs/op |
1 |
BenchmarkDocument/object_1000 |
1501172 ns/op 1428058 B/op 9849 allocs/op |
1422120 ns/op 1427910 B/op 9848 allocs/op |
1.06 |
BenchmarkDocument/object_1000 - ns/op |
1501172 ns/op |
1422120 ns/op |
1.06 |
BenchmarkDocument/object_1000 - B/op |
1428058 B/op |
1427910 B/op |
1.00 |
BenchmarkDocument/object_1000 - allocs/op |
9849 allocs/op |
9848 allocs/op |
1.00 |
BenchmarkDocument/object_10000 |
16652928 ns/op 12166817 B/op 100565 allocs/op |
15660224 ns/op 12168433 B/op 100571 allocs/op |
1.06 |
BenchmarkDocument/object_10000 - ns/op |
16652928 ns/op |
15660224 ns/op |
1.06 |
BenchmarkDocument/object_10000 - B/op |
12166817 B/op |
12168433 B/op |
1.00 |
BenchmarkDocument/object_10000 - allocs/op |
100565 allocs/op |
100571 allocs/op |
1.00 |
BenchmarkDocument/tree_100 |
1112947 ns/op 943705 B/op 6101 allocs/op |
1026064 ns/op 943700 B/op 6101 allocs/op |
1.08 |
BenchmarkDocument/tree_100 - ns/op |
1112947 ns/op |
1026064 ns/op |
1.08 |
BenchmarkDocument/tree_100 - B/op |
943705 B/op |
943700 B/op |
1.00 |
BenchmarkDocument/tree_100 - allocs/op |
6101 allocs/op |
6101 allocs/op |
1 |
BenchmarkDocument/tree_1000 |
82309430 ns/op 86460441 B/op 60114 allocs/op |
74695912 ns/op 86460301 B/op 60114 allocs/op |
1.10 |
BenchmarkDocument/tree_1000 - ns/op |
82309430 ns/op |
74695912 ns/op |
1.10 |
BenchmarkDocument/tree_1000 - B/op |
86460441 B/op |
86460301 B/op |
1.00 |
BenchmarkDocument/tree_1000 - allocs/op |
60114 allocs/op |
60114 allocs/op |
1 |
BenchmarkDocument/tree_10000 |
10374911886 ns/op 8580659120 B/op 600218 allocs/op |
9889640330 ns/op 8580651520 B/op 600211 allocs/op |
1.05 |
BenchmarkDocument/tree_10000 - ns/op |
10374911886 ns/op |
9889640330 ns/op |
1.05 |
BenchmarkDocument/tree_10000 - B/op |
8580659120 B/op |
8580651520 B/op |
1.00 |
BenchmarkDocument/tree_10000 - allocs/op |
600218 allocs/op |
600211 allocs/op |
1.00 |
BenchmarkDocument/tree_delete_all_1000 |
82170433 ns/op 87510457 B/op 75265 allocs/op |
75931913 ns/op 87509357 B/op 75265 allocs/op |
1.08 |
BenchmarkDocument/tree_delete_all_1000 - ns/op |
82170433 ns/op |
75931913 ns/op |
1.08 |
BenchmarkDocument/tree_delete_all_1000 - B/op |
87510457 B/op |
87509357 B/op |
1.00 |
BenchmarkDocument/tree_delete_all_1000 - allocs/op |
75265 allocs/op |
75265 allocs/op |
1 |
BenchmarkDocument/tree_edit_gc_100 |
4009413 ns/op 4146709 B/op 15141 allocs/op |
3850701 ns/op 4146822 B/op 15141 allocs/op |
1.04 |
BenchmarkDocument/tree_edit_gc_100 - ns/op |
4009413 ns/op |
3850701 ns/op |
1.04 |
BenchmarkDocument/tree_edit_gc_100 - B/op |
4146709 B/op |
4146822 B/op |
1.00 |
BenchmarkDocument/tree_edit_gc_100 - allocs/op |
15141 allocs/op |
15141 allocs/op |
1 |
BenchmarkDocument/tree_edit_gc_1000 |
343159941 ns/op 383746602 B/op 154873 allocs/op |
313007212 ns/op 383745640 B/op 154853 allocs/op |
1.10 |
BenchmarkDocument/tree_edit_gc_1000 - ns/op |
343159941 ns/op |
313007212 ns/op |
1.10 |
BenchmarkDocument/tree_edit_gc_1000 - B/op |
383746602 B/op |
383745640 B/op |
1.00 |
BenchmarkDocument/tree_edit_gc_1000 - allocs/op |
154873 allocs/op |
154853 allocs/op |
1.00 |
BenchmarkDocument/tree_split_gc_100 |
2681151 ns/op 2413328 B/op 11126 allocs/op |
2555546 ns/op 2413270 B/op 11125 allocs/op |
1.05 |
BenchmarkDocument/tree_split_gc_100 - ns/op |
2681151 ns/op |
2555546 ns/op |
1.05 |
BenchmarkDocument/tree_split_gc_100 - B/op |
2413328 B/op |
2413270 B/op |
1.00 |
BenchmarkDocument/tree_split_gc_100 - allocs/op |
11126 allocs/op |
11125 allocs/op |
1.00 |
BenchmarkDocument/tree_split_gc_1000 |
201756356 ns/op 222252916 B/op 122004 allocs/op |
185860623 ns/op 222253022 B/op 121994 allocs/op |
1.09 |
BenchmarkDocument/tree_split_gc_1000 - ns/op |
201756356 ns/op |
185860623 ns/op |
1.09 |
BenchmarkDocument/tree_split_gc_1000 - B/op |
222252916 B/op |
222253022 B/op |
1.00 |
BenchmarkDocument/tree_split_gc_1000 - allocs/op |
122004 allocs/op |
121994 allocs/op |
1.00 |
BenchmarkRPC/client_to_server |
364049641 ns/op 16584816 B/op 169196 allocs/op |
354775664 ns/op 16582717 B/op 169205 allocs/op |
1.03 |
BenchmarkRPC/client_to_server - ns/op |
364049641 ns/op |
354775664 ns/op |
1.03 |
BenchmarkRPC/client_to_server - B/op |
16584816 B/op |
16582717 B/op |
1.00 |
BenchmarkRPC/client_to_server - allocs/op |
169196 allocs/op |
169205 allocs/op |
1.00 |
BenchmarkRPC/client_to_client_via_server |
673098450 ns/op 34904964 B/op 324683 allocs/op |
648734258 ns/op 33592616 B/op 324015 allocs/op |
1.04 |
BenchmarkRPC/client_to_client_via_server - ns/op |
673098450 ns/op |
648734258 ns/op |
1.04 |
BenchmarkRPC/client_to_client_via_server - B/op |
34904964 B/op |
33592616 B/op |
1.04 |
BenchmarkRPC/client_to_client_via_server - allocs/op |
324683 allocs/op |
324015 allocs/op |
1.00 |
BenchmarkRPC/attach_large_document |
1359517281 ns/op 1896237280 B/op 8811 allocs/op |
1179218994 ns/op 1918305936 B/op 8818 allocs/op |
1.15 |
BenchmarkRPC/attach_large_document - ns/op |
1359517281 ns/op |
1179218994 ns/op |
1.15 |
BenchmarkRPC/attach_large_document - B/op |
1896237280 B/op |
1918305936 B/op |
0.99 |
BenchmarkRPC/attach_large_document - allocs/op |
8811 allocs/op |
8818 allocs/op |
1.00 |
BenchmarkRPC/adminCli_to_server |
557913918 ns/op 35957720 B/op 289553 allocs/op |
538411760 ns/op 35952048 B/op 289565 allocs/op |
1.04 |
BenchmarkRPC/adminCli_to_server - ns/op |
557913918 ns/op |
538411760 ns/op |
1.04 |
BenchmarkRPC/adminCli_to_server - B/op |
35957720 B/op |
35952048 B/op |
1.00 |
BenchmarkRPC/adminCli_to_server - allocs/op |
289553 allocs/op |
289565 allocs/op |
1.00 |
BenchmarkLocker |
64.19 ns/op 16 B/op 1 allocs/op |
64.19 ns/op 16 B/op 1 allocs/op |
1 |
BenchmarkLocker - ns/op |
64.19 ns/op |
64.19 ns/op |
1 |
BenchmarkLocker - B/op |
16 B/op |
16 B/op |
1 |
BenchmarkLocker - allocs/op |
1 allocs/op |
1 allocs/op |
1 |
BenchmarkLockerParallel |
40.2 ns/op 0 B/op 0 allocs/op |
40.24 ns/op 0 B/op 0 allocs/op |
1.00 |
BenchmarkLockerParallel - ns/op |
40.2 ns/op |
40.24 ns/op |
1.00 |
BenchmarkLockerParallel - B/op |
0 B/op |
0 B/op |
1 |
BenchmarkLockerParallel - allocs/op |
0 allocs/op |
0 allocs/op |
1 |
BenchmarkLockerMoreKeys |
156 ns/op 15 B/op 0 allocs/op |
148.8 ns/op 15 B/op 0 allocs/op |
1.05 |
BenchmarkLockerMoreKeys - ns/op |
156 ns/op |
148.8 ns/op |
1.05 |
BenchmarkLockerMoreKeys - B/op |
15 B/op |
15 B/op |
1 |
BenchmarkLockerMoreKeys - allocs/op |
0 allocs/op |
0 allocs/op |
1 |
BenchmarkChange/Push_10_Changes |
3934783 ns/op 115844 B/op 1214 allocs/op |
3848081 ns/op 116910 B/op 1215 allocs/op |
1.02 |
BenchmarkChange/Push_10_Changes - ns/op |
3934783 ns/op |
3848081 ns/op |
1.02 |
BenchmarkChange/Push_10_Changes - B/op |
115844 B/op |
116910 B/op |
0.99 |
BenchmarkChange/Push_10_Changes - allocs/op |
1214 allocs/op |
1215 allocs/op |
1.00 |
BenchmarkChange/Push_100_Changes |
15833955 ns/op 567690 B/op 6586 allocs/op |
15916199 ns/op 569798 B/op 6584 allocs/op |
0.99 |
BenchmarkChange/Push_100_Changes - ns/op |
15833955 ns/op |
15916199 ns/op |
0.99 |
BenchmarkChange/Push_100_Changes - B/op |
567690 B/op |
569798 B/op |
1.00 |
BenchmarkChange/Push_100_Changes - allocs/op |
6586 allocs/op |
6584 allocs/op |
1.00 |
BenchmarkChange/Push_1000_Changes |
129984095 ns/op 5221395 B/op 63079 allocs/op |
131534350 ns/op 5361392 B/op 63081 allocs/op |
0.99 |
BenchmarkChange/Push_1000_Changes - ns/op |
129984095 ns/op |
131534350 ns/op |
0.99 |
BenchmarkChange/Push_1000_Changes - B/op |
5221395 B/op |
5361392 B/op |
0.97 |
BenchmarkChange/Push_1000_Changes - allocs/op |
63079 allocs/op |
63081 allocs/op |
1.00 |
BenchmarkChange/Pull_10_Changes |
3174189 ns/op 101266 B/op 1019 allocs/op |
3089468 ns/op 102436 B/op 1018 allocs/op |
1.03 |
BenchmarkChange/Pull_10_Changes - ns/op |
3174189 ns/op |
3089468 ns/op |
1.03 |
BenchmarkChange/Pull_10_Changes - B/op |
101266 B/op |
102436 B/op |
0.99 |
BenchmarkChange/Pull_10_Changes - allocs/op |
1019 allocs/op |
1018 allocs/op |
1.00 |
BenchmarkChange/Pull_100_Changes |
4778147 ns/op 264190 B/op 3488 allocs/op |
4693999 ns/op 266418 B/op 3488 allocs/op |
1.02 |
BenchmarkChange/Pull_100_Changes - ns/op |
4778147 ns/op |
4693999 ns/op |
1.02 |
BenchmarkChange/Pull_100_Changes - B/op |
264190 B/op |
266418 B/op |
0.99 |
BenchmarkChange/Pull_100_Changes - allocs/op |
3488 allocs/op |
3488 allocs/op |
1 |
BenchmarkChange/Pull_1000_Changes |
9330563 ns/op 1489133 B/op 29859 allocs/op |
8990973 ns/op 1491039 B/op 29862 allocs/op |
1.04 |
BenchmarkChange/Pull_1000_Changes - ns/op |
9330563 ns/op |
8990973 ns/op |
1.04 |
BenchmarkChange/Pull_1000_Changes - B/op |
1489133 B/op |
1491039 B/op |
1.00 |
BenchmarkChange/Pull_1000_Changes - allocs/op |
29859 allocs/op |
29862 allocs/op |
1.00 |
BenchmarkSnapshot/Push_3KB_snapshot |
18832949 ns/op 700049 B/op 6589 allocs/op |
18601670 ns/op 707980 B/op 6586 allocs/op |
1.01 |
BenchmarkSnapshot/Push_3KB_snapshot - ns/op |
18832949 ns/op |
18601670 ns/op |
1.01 |
BenchmarkSnapshot/Push_3KB_snapshot - B/op |
700049 B/op |
707980 B/op |
0.99 |
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op |
6589 allocs/op |
6586 allocs/op |
1.00 |
BenchmarkSnapshot/Push_30KB_snapshot |
134487559 ns/op 5398167 B/op 63082 allocs/op |
133616227 ns/op 5650684 B/op 63080 allocs/op |
1.01 |
BenchmarkSnapshot/Push_30KB_snapshot - ns/op |
134487559 ns/op |
133616227 ns/op |
1.01 |
BenchmarkSnapshot/Push_30KB_snapshot - B/op |
5398167 B/op |
5650684 B/op |
0.96 |
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op |
63082 allocs/op |
63080 allocs/op |
1.00 |
BenchmarkSnapshot/Pull_3KB_snapshot |
7005665 ns/op 917631 B/op 15519 allocs/op |
6818214 ns/op 920377 B/op 15520 allocs/op |
1.03 |
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op |
7005665 ns/op |
6818214 ns/op |
1.03 |
BenchmarkSnapshot/Pull_3KB_snapshot - B/op |
917631 B/op |
920377 B/op |
1.00 |
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op |
15519 allocs/op |
15520 allocs/op |
1.00 |
BenchmarkSnapshot/Pull_30KB_snapshot |
16321963 ns/op 7154130 B/op 150123 allocs/op |
15935169 ns/op 7156656 B/op 150120 allocs/op |
1.02 |
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op |
16321963 ns/op |
15935169 ns/op |
1.02 |
BenchmarkSnapshot/Pull_30KB_snapshot - B/op |
7154130 B/op |
7156656 B/op |
1.00 |
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op |
150123 allocs/op |
150120 allocs/op |
1.00 |
BenchmarkSplayTree/stress_test_100000 |
0.1753 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/stress_test_100000 - ns/op |
0.1753 ns/op |
||
BenchmarkSplayTree/stress_test_100000 - B/op |
0 B/op |
||
BenchmarkSplayTree/stress_test_100000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/stress_test_200000 |
0.3718 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/stress_test_200000 - ns/op |
0.3718 ns/op |
||
BenchmarkSplayTree/stress_test_200000 - B/op |
0 B/op |
||
BenchmarkSplayTree/stress_test_200000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/stress_test_300000 |
0.5708 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/stress_test_300000 - ns/op |
0.5708 ns/op |
||
BenchmarkSplayTree/stress_test_300000 - B/op |
0 B/op |
||
BenchmarkSplayTree/stress_test_300000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/random_access_100000 |
0.01262 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/random_access_100000 - ns/op |
0.01262 ns/op |
||
BenchmarkSplayTree/random_access_100000 - B/op |
0 B/op |
||
BenchmarkSplayTree/random_access_100000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/random_access_200000 |
0.0236 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/random_access_200000 - ns/op |
0.0236 ns/op |
||
BenchmarkSplayTree/random_access_200000 - B/op |
0 B/op |
||
BenchmarkSplayTree/random_access_200000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/random_access_300000 |
0.03758 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/random_access_300000 - ns/op |
0.03758 ns/op |
||
BenchmarkSplayTree/random_access_300000 - B/op |
0 B/op |
||
BenchmarkSplayTree/random_access_300000 - allocs/op |
0 allocs/op |
||
BenchmarkSplayTree/editing_trace_bench |
0.002077 ns/op 0 B/op 0 allocs/op |
||
BenchmarkSplayTree/editing_trace_bench - ns/op |
0.002077 ns/op |
||
BenchmarkSplayTree/editing_trace_bench - B/op |
0 B/op |
||
BenchmarkSplayTree/editing_trace_bench - allocs/op |
0 allocs/op |
||
BenchmarkSync/memory_sync_10_test |
7142 ns/op 1287 B/op 38 allocs/op |
7084 ns/op 1286 B/op 38 allocs/op |
1.01 |
BenchmarkSync/memory_sync_10_test - ns/op |
7142 ns/op |
7084 ns/op |
1.01 |
BenchmarkSync/memory_sync_10_test - B/op |
1287 B/op |
1286 B/op |
1.00 |
BenchmarkSync/memory_sync_10_test - allocs/op |
38 allocs/op |
38 allocs/op |
1 |
BenchmarkSync/memory_sync_100_test |
51092 ns/op 8650 B/op 273 allocs/op |
51666 ns/op 8639 B/op 273 allocs/op |
0.99 |
BenchmarkSync/memory_sync_100_test - ns/op |
51092 ns/op |
51666 ns/op |
0.99 |
BenchmarkSync/memory_sync_100_test - B/op |
8650 B/op |
8639 B/op |
1.00 |
BenchmarkSync/memory_sync_100_test - allocs/op |
273 allocs/op |
273 allocs/op |
1 |
BenchmarkSync/memory_sync_1000_test |
590052 ns/op 74501 B/op 2130 allocs/op |
580200 ns/op 74391 B/op 2124 allocs/op |
1.02 |
BenchmarkSync/memory_sync_1000_test - ns/op |
590052 ns/op |
580200 ns/op |
1.02 |
BenchmarkSync/memory_sync_1000_test - B/op |
74501 B/op |
74391 B/op |
1.00 |
BenchmarkSync/memory_sync_1000_test - allocs/op |
2130 allocs/op |
2124 allocs/op |
1.00 |
BenchmarkSync/memory_sync_10000_test |
7406644 ns/op 734876 B/op 20259 allocs/op |
7245441 ns/op 736727 B/op 20258 allocs/op |
1.02 |
BenchmarkSync/memory_sync_10000_test - ns/op |
7406644 ns/op |
7245441 ns/op |
1.02 |
BenchmarkSync/memory_sync_10000_test - B/op |
734876 B/op |
736727 B/op |
1.00 |
BenchmarkSync/memory_sync_10000_test - allocs/op |
20259 allocs/op |
20258 allocs/op |
1.00 |
BenchmarkTextEditing |
5149537009 ns/op 3903608432 B/op 19608531 allocs/op |
5313285882 ns/op 3903631688 B/op 19608652 allocs/op |
0.97 |
BenchmarkTextEditing - ns/op |
5149537009 ns/op |
5313285882 ns/op |
0.97 |
BenchmarkTextEditing - B/op |
3903608432 B/op |
3903631688 B/op |
1.00 |
BenchmarkTextEditing - allocs/op |
19608531 allocs/op |
19608652 allocs/op |
1.00 |
BenchmarkTree/10000_vertices_to_protobuf |
3667404 ns/op 6263027 B/op 70025 allocs/op |
3524202 ns/op 6262969 B/op 70025 allocs/op |
1.04 |
BenchmarkTree/10000_vertices_to_protobuf - ns/op |
3667404 ns/op |
3524202 ns/op |
1.04 |
BenchmarkTree/10000_vertices_to_protobuf - B/op |
6263027 B/op |
6262969 B/op |
1.00 |
BenchmarkTree/10000_vertices_to_protobuf - allocs/op |
70025 allocs/op |
70025 allocs/op |
1 |
BenchmarkTree/10000_vertices_from_protobuf |
165095842 ns/op 442171322 B/op 290038 allocs/op |
160264126 ns/op 442172656 B/op 290039 allocs/op |
1.03 |
BenchmarkTree/10000_vertices_from_protobuf - ns/op |
165095842 ns/op |
160264126 ns/op |
1.03 |
BenchmarkTree/10000_vertices_from_protobuf - B/op |
442171322 B/op |
442172656 B/op |
1.00 |
BenchmarkTree/10000_vertices_from_protobuf - allocs/op |
290038 allocs/op |
290039 allocs/op |
1.00 |
BenchmarkTree/20000_vertices_to_protobuf |
8280650 ns/op 12716930 B/op 140028 allocs/op |
7653899 ns/op 12716871 B/op 140028 allocs/op |
1.08 |
BenchmarkTree/20000_vertices_to_protobuf - ns/op |
8280650 ns/op |
7653899 ns/op |
1.08 |
BenchmarkTree/20000_vertices_to_protobuf - B/op |
12716930 B/op |
12716871 B/op |
1.00 |
BenchmarkTree/20000_vertices_to_protobuf - allocs/op |
140028 allocs/op |
140028 allocs/op |
1 |
BenchmarkTree/20000_vertices_from_protobuf |
723958604 ns/op 1697263920 B/op 580043 allocs/op |
704471558 ns/op 1697267848 B/op 580043 allocs/op |
1.03 |
BenchmarkTree/20000_vertices_from_protobuf - ns/op |
723958604 ns/op |
704471558 ns/op |
1.03 |
BenchmarkTree/20000_vertices_from_protobuf - B/op |
1697263920 B/op |
1697267848 B/op |
1.00 |
BenchmarkTree/20000_vertices_from_protobuf - allocs/op |
580043 allocs/op |
580043 allocs/op |
1 |
BenchmarkTree/30000_vertices_to_protobuf |
12606559 ns/op 19318417 B/op 210030 allocs/op |
13003697 ns/op 19318419 B/op 210031 allocs/op |
0.97 |
BenchmarkTree/30000_vertices_to_protobuf - ns/op |
12606559 ns/op |
13003697 ns/op |
0.97 |
BenchmarkTree/30000_vertices_to_protobuf - B/op |
19318417 B/op |
19318419 B/op |
1.00 |
BenchmarkTree/30000_vertices_to_protobuf - allocs/op |
210030 allocs/op |
210031 allocs/op |
1.00 |
BenchmarkTree/30000_vertices_from_protobuf |
1694084216 ns/op 3752058896 B/op 870194 allocs/op |
1649891623 ns/op 3752053776 B/op 870143 allocs/op |
1.03 |
BenchmarkTree/30000_vertices_from_protobuf - ns/op |
1694084216 ns/op |
1649891623 ns/op |
1.03 |
BenchmarkTree/30000_vertices_from_protobuf - B/op |
3752058896 B/op |
3752053776 B/op |
1.00 |
BenchmarkTree/30000_vertices_from_protobuf - allocs/op |
870194 allocs/op |
870143 allocs/op |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Actionable comments posted: 11
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- test/bench/splay_tree_bench_test.go (1 hunks)
- test/bench/text_editing_bench_test.go (0 hunks)
- test/helper/helper.go (2 hunks)
💤 Files not reviewed due to no reviewable changes (1)
- test/bench/text_editing_bench_test.go
🧰 Additional context used
GitHub Check: build
test/bench/splay_tree_bench_test.go
[failure] 96-96:
Error return value oftree.Find
is not checked (errcheck)
[failure] 120-120:
Error return value oftree.Find
is not checked (errcheck)
[failure] 90-90:
G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
[failure] 98-98:
G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
[failure] 63-63:
error returned from external package is unwrapped: sig: func os.Open(name string) (*os.File, error) (wrapcheck)
[failure] 73-73:
error returned from external package is unwrapped: sig: func io.ReadAll(r io.Reader) ([]byte, error) (wrapcheck)test/helper/helper.go
[failure] 554-554:
error returned from external package is unwrapped: sig: func os.Open(name string) (*os.File, error) (wrapcheck)
[failure] 564-564:
error returned from external package is unwrapped: sig: func io.ReadAll(r io.Reader) ([]byte, error) (wrapcheck)
[failure] 568-568:
error returned from external package is unwrapped: sig: func encoding/json.Unmarshal(data []byte, v any) error (wrapcheck)
[failure] 571-571:
error returned from external package is unwrapped: sig: func encoding/json.Unmarshal(data []byte, v any) error (wrapcheck)
🔇 Additional comments not posted (3)
test/helper/helper.go (1)
542-572
: Overall assessment of changesThe additions to this file introduce a new struct
editTrace
and a functionreadEditingTraceFromFile
for reading editing traces from a JSON file. While these changes are not directly related to the PR objectives mentioned earlier (fixing splay operations in Find and IndexOf functions), they appear to be helper utilities for testing or benchmarking purposes.The implementation is generally good, but there are opportunities for improvement in error handling and making the function more generic, as detailed in the previous comments.
It's worth noting that these changes don't seem to address the core objectives of the PR. Could you please clarify how these additions relate to fixing the splay tree implementation or if they are intended for a different purpose?
🧰 Tools
GitHub Check: build
[failure] 554-554:
error returned from external package is unwrapped: sig: func os.Open(name string) (*os.File, error) (wrapcheck)
[failure] 564-564:
error returned from external package is unwrapped: sig: func io.ReadAll(r io.Reader) ([]byte, error) (wrapcheck)
[failure] 568-568:
error returned from external package is unwrapped: sig: func encoding/json.Unmarshal(data []byte, v any) error (wrapcheck)
[failure] 571-571:
error returned from external package is unwrapped: sig: func encoding/json.Unmarshal(data []byte, v any) error (wrapcheck)test/bench/splay_tree_bench_test.go (2)
90-90
: Usage ofmath/rand
is acceptable for benchmarkingThe static analysis tool flags the use of
math/rand
at line 90, suggestingcrypto/rand
for secure random number generation. However, for benchmarking purposes,math/rand
is appropriate due to its performance and ease of use.🧰 Tools
GitHub Check: build
[failure] 90-90:
G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
98-98
: Usage ofmath/rand
is acceptable for benchmarkingAs mentioned previously, the use of
math/rand
at line 98 is appropriate in this benchmarking context despite the static analysis warning.🧰 Tools
GitHub Check: build
[failure] 98-98:
G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
Restored the readEditingTraceFromFile function that was accidentally deleted.
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.
Thanks for your contribution.
find
performs splay
Enhance splay tree efficiency by incorporating splay operations after node location in Find and IndexOf functions. This change maintains the tree's self-balancing property and ensures amortized O(log n) time complexity for future operations. Simplify IndexOf() by leveraging the splay operation, reducing additional traversal logic and improving overall performance.
Added splay operation after locating the node in the Find function. Simplified IndexOf() function by utilizing the splay operation, reducing the need for additional traversal logic and ensuring efficient access.
By incorporating splay in both functions, the tree maintains its self-balancing property and ensures amortized O(log n) time complexity for future operations.
What this PR does / why we need it:
This PR addresses a critical issue in the splay tree implementation where the Find and IndexOf functions do not perform the necessary splay operation after locating a node. By ensuring that these functions splay the accessed node to the root, we maintain the amortized O(log n) time complexity for subsequent operations. This enhancement optimizes the overall efficiency and performance of the splay tree, ensuring that frequently accessed nodes remain close to the root and improving access times for future queries.
Which issue(s) this PR fixes:
Fixes #1016
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
IndexOf
andFind
functionalities for improved efficiency in tree operations.Bug Fixes
Documentation