Improve perf/codegen #94

Merged
andrew merged 5 commits from perf into main 2026-10-27 20:45:53 +00:00
2 changed files with 23 additions and 22 deletions
Showing only changes of commit 3b4271dac1 - Show all commits

No files matched your search

+21 -21
View File
@@ -19,30 +19,30 @@ InstalledDir: /usr/lib/llvm-21/bin
| ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark | ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
| 164.29 | 6,086,873.38 | 0.0% | 3,107.03 | 604.19 | 5.142 | 558.59 | 0.0% | 1.96 | `point reads` | 165.35 | 6,047,750.85 | 0.1% | 3,107.03 | 608.25 | 5.108 | 558.59 | 0.0% | 1.98 | `point reads`
| 161.05 | 6,209,395.38 | 0.1% | 3,036.76 | 592.21 | 5.128 | 539.35 | 0.0% | 1.93 | `prefix reads` | 161.75 | 6,182,478.30 | 0.2% | 3,036.76 | 594.75 | 5.106 | 539.35 | 0.0% | 1.94 | `prefix reads`
| 239.55 | 4,174,539.38 | 0.1% | 3,722.71 | 880.68 | 4.227 | 692.00 | 0.0% | 2.86 | `range reads` | 250.88 | 3,985,953.69 | 0.4% | 3,722.71 | 922.20 | 4.037 | 692.00 | 0.0% | 2.98 | `range reads`
| 354.75 | 2,818,919.14 | 0.7% | 4,523.64 | 1,304.75 | 3.467 | 720.22 | 2.0% | 4.23 | `point writes` | 358.34 | 2,790,617.48 | 0.2% | 4,523.64 | 1,317.11 | 3.435 | 720.22 | 2.1% | 4.28 | `point writes`
| 345.32 | 2,895,878.47 | 0.1% | 4,484.57 | 1,270.31 | 3.530 | 705.00 | 1.8% | 4.12 | `prefix writes` | 349.16 | 2,864,048.29 | 0.9% | 4,484.57 | 1,279.36 | 3.505 | 705.00 | 1.9% | 4.16 | `prefix writes`
| 193.48 | 5,168,547.42 | 0.1% | 2,224.10 | 711.72 | 3.125 | 377.17 | 3.3% | 2.32 | `range writes` | 192.06 | 5,206,715.53 | 0.0% | 2,224.10 | 706.55 | 3.148 | 377.17 | 3.3% | 2.30 | `range writes`
| 404.89 | 2,469,777.50 | 2.4% | 6,855.96 | 1,489.70 | 4.602 | 1,227.82 | 1.3% | 0.05 | `monotonic increasing point writes` | 408.59 | 2,447,415.85 | 0.9% | 6,855.96 | 1,503.60 | 4.560 | 1,227.82 | 1.4% | 0.05 | `monotonic increasing point writes`
| 134,231.80 | 7,449.80 | 1.9% | 812,045.25 | 495,770.40 | 1.638 | 151,246.50 | 0.9% | 0.01 | `worst case for radix tree` | 136,536.00 | 7,324.08 | 2.0% | 812,045.00 | 501,448.67 | 1.619 | 151,246.43 | 0.9% | 0.01 | `worst case for radix tree`
| 37.80 | 26,454,311.17 | 0.4% | 701.00 | 139.14 | 5.038 | 102.00 | 0.0% | 0.01 | `create and destroy` | 37.84 | 26,426,456.12 | 0.8% | 701.00 | 139.27 | 5.034 | 102.00 | 0.0% | 0.01 | `create and destroy`
## Radix tree (this implementation) ## Radix tree (this implementation)
| ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark | ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
| 12.89 | 77,565,115.56 | 0.1% | 244.55 | 47.43 | 5.155 | 34.21 | 0.6% | 0.15 | `point reads` | 12.44 | 80,368,377.55 | 0.2% | 237.48 | 45.74 | 5.192 | 31.23 | 0.8% | 0.15 | `point reads`
| 15.11 | 66,162,047.76 | 0.1% | 297.79 | 55.60 | 5.356 | 43.23 | 0.4% | 0.18 | `prefix reads` | 14.59 | 68,537,989.62 | 0.6% | 291.66 | 53.69 | 5.432 | 40.16 | 0.5% | 0.17 | `prefix reads`
| 36.29 | 27,559,358.29 | 0.1% | 783.16 | 133.44 | 5.869 | 109.52 | 0.2% | 0.43 | `range reads` | 33.91 | 29,487,389.82 | 0.1% | 759.22 | 124.80 | 6.084 | 101.27 | 0.2% | 0.41 | `range reads`
| 20.53 | 48,719,405.55 | 0.1% | 381.81 | 75.51 | 5.057 | 51.04 | 0.5% | 0.25 | `point writes` | 19.54 | 51,172,096.42 | 0.0% | 369.51 | 71.92 | 5.138 | 47.92 | 0.5% | 0.23 | `point writes`
| 39.37 | 25,402,042.40 | 0.1% | 685.00 | 144.83 | 4.730 | 106.72 | 0.3% | 0.47 | `prefix writes` | 37.87 | 26,402,961.91 | 0.1% | 662.02 | 139.34 | 4.751 | 100.26 | 0.4% | 0.45 | `prefix writes`
| 43.78 | 22,843,841.63 | 0.1% | 800.40 | 161.06 | 4.970 | 127.36 | 0.1% | 0.53 | `range writes` | 39.11 | 25,569,264.79 | 0.1% | 725.90 | 143.87 | 5.046 | 111.09 | 0.1% | 0.48 | `range writes`
| 78.37 | 12,760,008.75 | 1.0% | 1,452.61 | 288.24 | 5.040 | 278.69 | 0.1% | 0.01 | `monotonic increasing point writes` | 77.70 | 12,869,910.98 | 0.5% | 1,430.41 | 286.41 | 4.994 | 271.78 | 0.1% | 0.01 | `monotonic increasing point writes`
| 322,885.50 | 3,097.07 | 1.5% | 4,362,382.00 | 1,183,852.00 | 3.685 | 765,301.00 | 0.1% | 0.01 | `worst case for radix tree` | 319,309.00 | 3,131.76 | 0.5% | 4,181,645.50 | 1,178,098.50 | 3.549 | 728,511.00 | 0.1% | 0.01 | `worst case for radix tree`
| 99.99 | 10,000,718.79 | 0.4% | 1,775.00 | 367.93 | 4.824 | 288.00 | 0.0% | 0.01 | `create and destroy` | 97.89 | 10,215,764.97 | 0.3% | 1,775.00 | 360.36 | 4.926 | 288.00 | 0.0% | 0.01 | `create and destroy`
# "Real data" test # "Real data" test
@@ -51,13 +51,13 @@ Point queries only. Gc ratio is the ratio of time spent doing garbage collection
## skip list ## skip list
``` ```
Check: 4.62967 seconds, 352.195 MB/s, Add: 3.34177 seconds, 167.771 MB/s, Gc ratio: 37.9399%, Peak idle memory: 5.51852e+06 Check: 4.7186 seconds, 345.557 MB/s, Add: 3.3305 seconds, 168.339 MB/s, Gc ratio: 38.6509%, Peak idle memory: 5.51852e+06
``` ```
## radix tree ## radix tree
``` ```
Check: 1.00477 seconds, 1622.8 MB/s, Add: 1.21142 seconds, 462.808 MB/s, Gc ratio: 39.4716%, Peak idle memory: 2.0226e+06 Check: 0.992421 seconds, 1643 MB/s, Add: 1.21864 seconds, 460.066 MB/s, Gc ratio: 38.8025%, Peak idle memory: 2.0226e+06
``` ```
## hash table ## hash table
@@ -65,6 +65,6 @@ Check: 1.00477 seconds, 1622.8 MB/s, Add: 1.21142 seconds, 462.808 MB/s, Gc rati
(The hash table implementation doesn't work on range queries, and its purpose is to provide an idea of how fast point queries can be) (The hash table implementation doesn't work on range queries, and its purpose is to provide an idea of how fast point queries can be)
``` ```
Check: 0.854254 seconds, 1908.74 MB/s, Add: 0.632626 seconds, 886.232 MB/s, Gc ratio: 41.0827%, Peak idle memory: 0 Check: 0.855247 seconds, 1906.52 MB/s, Add: 0.63138 seconds, 887.98 MB/s, Gc ratio: 41.2278%, Peak idle memory: 0
``` ```
+2 -1
View File
@@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
# Disable frequency scaling # Disable frequency scaling
for i in $(seq "$(nproc)") ; do sudo cat /sys/devices/system/cpu/cpu$((i-1))/cpufreq/scaling_max_freq | sudo tee /sys/devices/system/cpu/cpu$((i-1))/cpufreq/scaling_min_freq >/dev/null ; done # shellcheck disable=SC2002
for i in $(seq "$(nproc)") ; do cat /sys/devices/system/cpu/cpu$((i-1))/cpufreq/scaling_max_freq | sudo tee /sys/devices/system/cpu/cpu$((i-1))/cpufreq/scaling_min_freq >/dev/null ; done
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_FLAGS=-DNVALGRIND > /dev/null cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_FLAGS=-DNVALGRIND > /dev/null
cmake --build build > /dev/null cmake --build build > /dev/null