perf(serialize): optimized sorting algorithm#151
Open
zsilbi wants to merge 19 commits intoperf/faster-comparefrom
Open
perf(serialize): optimized sorting algorithm#151zsilbi wants to merge 19 commits intoperf/faster-comparefrom
zsilbi wants to merge 19 commits intoperf/faster-comparefrom
Conversation
1 task
74c561b to
552c05b
Compare
Member
|
Do you recall if we have the same trade-off in v8 based runtimes / Node.js specifically? |
Collaborator
Author
I ran this again on This is small object with 5 keys in random order. clk: ~5.25 GHz
cpu: AMD Ryzen 9 7950X 16-Core Processor
runtime: node 23.9.0 (x64-linux)
benchmark avg (min … max) p75 / p99 (min … top 1%)
------------------------------------------- -------------------------------
• count:1, size:small
------------------------------------------- -------------------------------
ohash @ d7f7f9d 260.16 ns/iter 260.28 ns ▃█
(239.77 ns … 686.80 ns) 434.16 ns ▆██
( 1.78 kb … 2.09 kb) 1.84 kb ███▅▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
4.16 ipc ( 95.84% cache) 0.64 branch misses
1.37k cycles 5.69k instructions 73.30 c-refs 3.05 c-misses
ohash @ dev 193.24 ns/iter 200.30 ns █
(181.85 ns … 286.39 ns) 227.37 ns ▅██
(787.89 b … 1.29 kb) 992.75 b ▃███▆▄▃▃▆▇▆▅▃▂▂▁▂▁▁▁▁
4.41 ipc ( 96.45% cache) 0.18 branch misses
1.02k cycles 4.48k instructions 41.53 c-refs 1.48 c-misses
summary
ohash @ dev
1.35x faster than ohash @ d7f7f9d
• count:256, size:small
------------------------------------------- -------------------------------
ohash @ d7f7f9d 74.17 µs/iter 69.04 µs █▆
(63.98 µs … 459.12 µs) 215.41 µs ██
( 14.24 kb … 779.95 kb) 461.35 kb ██▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
3.92 ipc ( 95.74% cache) 526.21 branch misses
390.40k cycles 1.53M instructions 22.40k c-refs 953.59 c-misses
ohash @ dev 57.23 µs/iter 54.75 µs █
(50.63 µs … 377.78 µs) 217.18 µs █
( 13.18 kb … 450.00 kb) 239.15 kb █▇▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
4.17 ipc ( 96.48% cache) 367.38 branch misses
299.92k cycles 1.25M instructions 13.98k c-refs 492.69 c-misses
summary
ohash @ dev
1.3x faster than ohash @ d7f7f9d |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For smaller object keys and
Setvalues with less than ~10 elements (which is quite common) we can use a simple insertion sort.Otherwise we fall back to the native
sort().Compared to target: #144