Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Benchmarks

These measurements come from one machine at the source revisions listed in Setup and Reproduction.

How to Read the Results

MetricWhat each value measuresBetter
ns/key or ns/elementMedian timed workload divided by the input size, n. Some workloads perform more or fewer than n calls.Lower
ns/queryMedian time per ordered query. A range query can visit many entries.Lower
Bytes/key or MBLive bytes requested from Rust’s global allocator at the stated checkpoint. MB is 1,000,000 bytes.Lower
ThroughputThe stated unit of work divided by median elapsed wall time, in millions per second. See each table for what counts as one unit.Higher
SpeedupThroughput at the stated worker count divided by throughput for the same workload on one thread.Higher

In each timing table, n is the number of input entries or the starting container size. A dash means no measurement is reported. Bold highlights the lowest time in the Rust timing tables and the highest throughput in the Python FIFO table. Small gaps on this machine are weak evidence of a performance difference.

Comparison Implementations

WorkloadBaselines
Keyed maps and setshashbrown::HashMap and hashbrown::HashSet (0.17.1) with rustc_hash::FxHasher (2.1.3), plus Rust’s BTreeMap and BTreeSet.
Direct indexingVecOption and VecBool are benchmark wrappers around Vec<Option<u64>> and Vec<bool>, respectively. They allocate one slot per index through the highest key and run only where that fits the harness’s size limit.
Rust priority queuepriority_queue::PriorityQueue (2.7.0), an indexed heap, and BinaryHeap, a standard-library heap with push and pop.
SequencesRust’s Vec and VecDeque.
Generational idsSlotMap and DenseSlotMap (1.1.1), slab::Slab (0.4.12), and thunderdome::Arena (0.6.1). IdAllocatorIdMap is this package’s IdAllocator paired with a PagedSparseMap<Id, u64>. A slab uses reusable integer keys.
Python FIFOCPython’s collections.deque and queue.SimpleQueue.
Python priority queuesCPython’s heapq on (priority, key) tuples, with a dictionary for lazy invalidation in the update workload or a threading.Lock for the multi-worker workload.

Keyed Collections

These tables compare sparse maps, sparse sets, and direct maps with the linked baseline implementations. PagedDirectMapFlat and PagedDirectMapRadix use the same map with different page directories.

WorkloadTimed work
InsertBuild from n keys in pattern order, including allocation.
HitLook up each present key once in shuffled order.
MissLook up n absent keys from a disjoint part of the same pattern.
IterateTraverse the entries and fold them into a checksum.
RemoveRemove all keys from a prebuilt container in shuffled order.

Dense keys are 0..n. Clustered keys form runs of 64 consecutive integers with run starts spread across the u32 range. Uniform keys come from a pseudo-random permutation of u32. The harness skips the 10⁷-key uniform cases because of the cost of allocating and initializing many pages.

For 10⁵ dense keys, the flat direct map took 4.25 ns/hit against 10.9 for hashbrown, and the sparse map iterated at 0.265 ns/entry against 1.84. For 10⁵ uniform keys, hashbrown inserted at 33.1 ns/key in the sparse-map comparison, against 3,345 for the sparse map. Use the key pattern closest to your workload when reading the tables.

Sparse Map (u32 -> u64)

Dense keys (ns/key)
n, opPagedSparseMapHashMapBTreeMapVecOption
10³ insert6.4424.175.24.7
10³ hit2.85.2645.61.15
10³ miss1.244.1324.40.779
10³ iterate0.1552.022.760.578
10³ remove8.0210.493.51.05
10⁵ insert6.0533.999.86.42
10⁵ hit8.94111322.57
10⁵ miss1.18842.80.803
10⁵ iterate0.2651.843.050.699
10⁵ remove23.216.817819.8
10⁷ insert1413014514.2
10⁷ hit47.942.345014.5
10⁷ miss1.188.4266.50.826
10⁷ iterate0.9073.868.872.27
10⁷ remove194141543107
Clustered keys (ns/key)
n, opPagedSparseMapHashMapBTreeMapVecOption
10³ insert41.125.875.657.4
10³ hit2.945.2349.61.15
10³ miss1.224.1528.60.762
10³ iterate0.1551.822.7518,291
10³ remove24.410.493.520.4
10⁵ insert21232.6116–
10⁵ hit15.611.3134–
10⁵ miss1.537.7335–
10⁵ iterate0.2631.833.23–
10⁵ remove10922179–
10⁷ insert56.8140147–
10⁷ hit60.341.5467–
10⁷ miss2.8913.251.5–
10⁷ iterate0.8943.99.91–
10⁷ remove307129573–
Uniform keys (ns/key)
n, opPagedSparseMapHashMapBTreeMapVecOption
10³ insert82526.883.6–
10³ hit5.45.2446.9–
10³ miss1.225.0224.7–
10³ iterate0.1551.83.06–
10³ remove28610.493.8–
10⁵ insert3,34533.1113–
10⁵ hit24.911.4133–
10⁵ miss410.778.8–
10⁵ iterate0.2651.843.68–
10⁵ remove81322.6172–

Sparse Set (u32)

Dense keys (ns/key)
n, opPagedSparseSetHashSetBTreeSetVecBool
10³ insert6.221.963.93.47
10³ hit2.694.8248.70.967
10³ miss1.014.4724.70.878
10³ iterate0.2071.682.780.571
10³ remove4.661185.30.906
10⁵ insert5.6928.589.33.32
10⁵ hit6.79.821281.24
10⁵ miss0.9957.8342.70.872
10⁵ iterate0.2111.572.930.558
10⁵ remove11.716.41575.78
10⁷ insert9.49571203.55
10⁷ hit31.136.13663.88
10⁷ miss1.017.9366.50.887
10⁷ iterate0.3411.934.910.565
10⁷ remove12811343321.5
Clustered keys (ns/key)
n, opPagedSparseSetHashSetBTreeSetVecBool
10³ insert41.523.864.11,557
10³ hit2.744.8348.60.952
10³ miss0.9994.4824.30.878
10³ iterate0.2071.542.7817,803
10³ remove20.71178.91.43
10⁵ insert2072791.3–
10⁵ hit11.810.1130–
10⁵ miss1.267.6734.8–
10⁵ iterate0.211.783.02–
10⁵ remove99.821.9157–
10⁷ insert46.575148–
10⁷ hit42.138.1394–
10⁷ miss2.6312.255–
10⁷ iterate0.3432.39.31–
10⁷ remove238109437–
Uniform keys (ns/key)
n, opPagedSparseSetHashSetBTreeSetVecBool
10³ insert83724.469.9–
10³ hit4.494.8148.9–
10³ miss0.9995.2324.7–
10³ iterate0.2071.543.11–
10³ remove27011.179.1–
10⁵ insert3,30027.7103–
10⁵ hit22.910.1128–
10⁵ miss3.7410.576.2–
10⁵ iterate0.211.773.63–
10⁵ remove79722.4151–

Direct Map (u32 -> u64)

Dense keys (ns/key)
n, opPagedDirectMapFlatPagedDirectMapRadixHashMapBTreeMapVecOption
10³ insert4.697.324.780.14.62
10³ hit2.372.38545.11.15
10³ miss1.211.24.1124.40.764
10³ iterate2.252.551.722.760.564
10³ remove2.312.610.493.91.06
10⁵ insert5.137.6633.91116.41
10⁵ hit4.254.2610.91312.56
10⁵ miss1.191.18842.80.801
10⁵ iterate2.252.541.613.080.692
10⁵ remove4.14.5317.117819.7
10⁷ insert716.313114714.2
10⁷ hit19.219.342.145114.6
10⁷ miss1.21.28.0166.30.828
10⁷ iterate2.562.823.839.542.26
10⁷ remove29.330.4140539106
Clustered keys (ns/key)
n, opPagedDirectMapFlatPagedDirectMapRadixHashMapBTreeMapVecOption
10³ insert50.838.526.481.356.4
10³ hit2.49174.9145.11.15
10³ miss1.22.624.1224.40.763
10³ iterate60.239.91.552.7418,305
10³ remove19.118.210.39420.8
10⁵ insert24999.232.6115–
10⁵ hit10.537.711133–
10⁵ miss1.53137.4935.1–
10⁵ iterate75.139.91.793.25–
10⁵ remove84.141.522.1179–
10⁷ insert161200128142–
10⁷ hit26.710841.5468–
10⁷ miss2.8516.512.749.3–
10⁷ iterate33.247.43.9110.3–
10⁷ remove177196125569–
Uniform keys (ns/key)
n, opPagedDirectMapFlatPagedDirectMapRadixHashMapBTreeMapVecOption
10³ insert8,6876,4012785.3–
10³ hit4.61215.1647–
10³ miss1.192.62524.7–
10³ iterate1,2082,4891.563.04–
10³ remove1,06580710.694.4–
10⁵ insert10,97411,03333113–
10⁵ hit23.369.111.1132–
10⁵ miss3.9526.110.478–
10⁵ iterate2,0933,0011.793.67–
10⁵ remove1,4841,06222.6173–

Ordered Queries

The input is dense. Each measurement issues 1,000 queries from shuffled starting keys and reports ns/query. next finds the first entry at or after the starting key, using BTreeMap::range(k..).next() for the baseline. range_1000 visits entries within a 1,000-key window. Windows near the end of the input can contain fewer entries.

n, queryPagedDirectMapFlatPagedDirectMapRadixBTreeMap
10³ next18.739.552.2
10⁵ next20.242.4129
10⁷ next21.944.9270
10³ range_10003,9672,9701,324
10⁵ range_10007,9305,7992,989
10⁷ range_10008,0125,8633,252

At 10⁵ keys, a flat direct-map next query took 20.2 ns versus 129 ns for the B-tree. At the same size, scanning the window took 7,930 ns for the flat direct map and 2,989 ns for the B-tree.

Memory

Tables report bytes/key after building the container: live allocator bytes above the pre-build baseline divided by n. Input key arrays are allocated before that baseline. RSS, allocator bookkeeping and temporary peak allocations are outside this metric.

Sparse Map

pattern, nPagedSparseMapHashMapBTreeMapVecOption
dense 10³16.434.826.416
dense 10⁵19.822.326.316
dense 10⁷24.128.526.316
clustered 10³34334.826.4506,344
clustered 10⁵41922.325.8–
clustered 10⁷87.528.525.8–
uniform 10³6,27934.824.3–
uniform 10⁵4,45922.319.7–

Sparse Set

pattern, nPagedSparseSetHashSetBTreeSetVecBool
dense 10³8.2210.311.71
dense 10⁵9.276.5511.61
dense 10⁷10.78.3911.61
clustered 10³33510.311.731,647
clustered 10⁵4096.5511.3–
clustered 10⁷74.18.3911.3–
uniform 10³6,27110.310.7–
uniform 10⁵4,4496.558.53–

Direct Map

pattern, nPagedDirectMapFlatPagedDirectMapRadixHashMapBTreeMapVecOption
dense 10³16.416.434.826.416
dense 10⁵16.116.122.326.316
dense 10⁷161628.526.316
clustered 10³52726334.826.4506,344
clustered 10⁵59625722.325.8–
clustered 10⁷25926028.525.8–
uniform 10³18,55516,43534.824.3–
uniform 10⁵16,73116,63922.319.7–

In this run a sparse index page used 4 bytes per slot and a direct-map page used 16 bytes per slot (u32 -> u64). A single 64-key run fills 6% of a 1,024-slot page. Widely scattered keys leave many pages with just a few live slots. The directory and any dense arrays also contribute to the total.

Removal and Shrinking

The harness builds each container, randomly removes 90% of its entries, then calls shrink_to_fit where available. The three columns show live allocations in MB at those checkpoints. BTreeMap frees nodes during removal. The Hive row also includes the benchmark’s vector of ids kept for removal.

ContainerPatternnBuiltAfter removalAfter shrink
PagedSparseMapuniform10⁵445.9445.9443.3
PagedDirectMapFlatuniform10⁵1,673.11,673.1197.4
PagedDirectMapRadixuniform10⁵1,663.91,663.9170.1
HashMapuniform10⁵2.22.20.3
BTreeMapuniform10⁵2.00.20.2
PagedSparseMapdense10⁷241.5241.552.1
PagedDirectMapFlatdense10⁷160.1160.1160.1
PagedDirectMapRadixdense10⁷160.1160.1160.1
HashMapdense10⁷285.2285.235.7
BTreeMapdense10⁷262.922.722.7
PagedSparseMapclustered10⁷875.3875.3685.6
PagedDirectMapFlatclustered10⁷2,594.02,594.02,590.6
PagedDirectMapRadixclustered10⁷2,603.62,603.62,592.8
HashMapclustered10⁷285.2285.235.7
BTreeMapclustered10⁷257.722.722.7
Hivesequential10⁷240.7240.8240.5

For uniform keys at 10⁵ entries, the flat direct map dropped from 1,673.1 MB to 197.4 MB after shrinking. For dense 10⁷ keys, almost every page still contained survivors, and memory held at 160.1 MB. The sparse map can shrink its dense arrays even when index pages remain allocated.

Page Size

The sweep changes the number of slots per page with Flat at 10⁵ keys. Timing is the median of seven samples divided by n. Bytes/key uses the live size after construction, also divided by n.

Sparse Map

PatternMeasurePAGE=64PAGE=256PAGE=1024PAGE=4096PAGE=16384
denseinsert ns/key11.311.110.610.410.5
densehit ns/key11.811.611.411.411.4
denseiterate ns/key0.2660.2670.2660.2660.267
densebytes/key19.919.819.819.820.3
clusteredinsert ns/key2,63266918740602
clusteredhit ns/key17.518.11919.218.1
clusterediterate ns/key0.2660.2660.2660.2670.267
clusteredbytes/key5,4521,3904193571,061
uniforminsert ns/key3,6431,2782,5369,92626,248
uniformhit ns/key27.528.92825.624
uniformiterate ns/key0.2670.2670.2660.2670.267
uniformbytes/key5,8102,4254,45916,48842,988

Direct Map

PatternMeasurePAGE=64PAGE=256PAGE=1024PAGE=4096PAGE=16384
denseinsert ns/key6.045.195.025.025.47
densehit ns/key5.855.725.675.675.67
denseiterate ns/key2.242.242.252.252.25
densebytes/key16.216.116.116.418.4
clusteredinsert ns/key2,6156632105922,384
clusteredhit ns/key10.111.912.312.410.4
clusterediterate ns/key1,00226287.8136481
clusteredbytes/key5,4481,4225961,1094,119
uniforminsert ns/key3,7973,2519,69537,356–
uniformhit ns/key26.527.123.721.8–
uniformiterate ns/key1,5048992,1067,753–
uniformbytes/key6,5625,48116,73165,624–

Small pages waste less memory per partly filled page, but with Flat the directory holds one pointer for each page up to the highest key: for keys spread over the u32 range, PAGE = 64 makes a 512 MiB directory, which dominates the memory column. 1024 is the default because it is close to the best across patterns. On dense keys the page size barely matters.

Priority Queue

The Rust paged priority queue and the priority-queue crate both support priority changes by key. BinaryHeap runs only the push and pop cases. Each value is ns per input element.

WorkloadTimed work
pushBuild by pushing n entries into an empty heap.
change_priorityChange n/2 priorities in a prebuilt heap. The table divides by n; multiply by two for ns per update.
pop_allDrain a prebuilt heap in priority order, stopping at empty.
n, opPagedPriorityQueuepriority-queueBinaryHeap
10³ push18.1647.74
10⁵ push17.81119.72
10⁷ push28.939020.7
10³ change_priority7.3928.7–
10⁵ change_priority18.485.4–
10⁷ change_priority145551–
10³ pop_all71.110948.3
10⁵ pop_all161319155
10⁷ pop_all6322,329564

At 10⁵ entries, the paged heap took 17.8 ns/element to push versus 111 for the indexed crate and 9.72 for BinaryHeap. Its priority changes took 18.4 ns per input element versus 85.4 for the indexed crate.

Paged Vector and Deque

Timings are ns per input element. The vector’s random_get and the deque’s random_index each look up n shuffled positions. One queue_churn step is a front pop followed by a back push, repeated n times on a full deque.

Vector

n, opPagedVecVec
10³ push2.852.29
10⁵ push2.951.68
10⁷ push7.965.09
10³ random_get2.231.21
10⁵ random_get2.231.21
10⁷ random_get3.221.4
10³ iterate0.3940.381
10⁵ iterate0.3940.372
10⁷ iterate0.3950.372
10³ sum0.4870.155
10⁵ sum0.5120.266
10⁷ sum1.050.9

Deque

n, opPagedDequeVecDeque
10³ push_front4.963.84
10⁵ push_front5.623.34
10⁷ push_front9.789.73
10³ queue_churn8.84.98
10⁵ queue_churn8.274.94
10⁷ queue_churn9.049.17
10³ random_index2.521.74
10⁵ random_index2.511.73
10⁷ random_index2.681.87

Iteration matches Vec. Indexing costs one extra indirection (1 to 2 ns). At 10⁷ elements the deque is level with VecDeque, whose growth copies every element; at small sizes VecDeque is faster.

Generational Ids

Timings are ns per input element. insert builds n entries, get looks up all ids in shuffled order, and iterate visits the live entries. remove_half_reinsert removes half the original entries and inserts as many again. See the baseline descriptions for the different handle types.

n, opHiveIdAllocatorIdMapSlotMapDenseSlotMapSlabArena
10³ insert9.319.37.7312.97.766.37
10⁵ insert15.618.18.2712.37.977.93
10⁷ insert24.335.920.129.519.719.9
10³ get4.194.842.923.371.72.61
10⁵ get6.9411.55.27.193.334.08
10⁷ get315922.436.916.918.3
10³ iterate0.8840.1561.40.460.8850.882
10⁵ iterate0.9850.2641.40.5010.8840.931
10⁷ iterate2.340.8952.361.052.322.36
10³ remove_half_reinsert8.615.83.716.53.734.92
10⁵ remove_half_reinsert12.13413.129.513.214.5
10⁷ remove_half_reinsert41.929367.117967.772.2

Hive keeps elements at stable addresses and pays for it on raw lookup speed against slotmap, slab and thunderdome, which store values in one growable vector. IdAllocator + PagedSparseMap also keeps values in a dense vector, so removal can move the last value; its cost is the extra index lookup.

Concurrent Scaling

Rust

The Rust scaling harness uses 2 million shuffled keys as work items and splits them across workers. The table divides the count of work items by the median of seven wall times. One item is one key or id processed, or one increment in the shared-counter reference. Churn counts insertions or allocations, with removal or freeing included in the timer. A batch call counts each key it processes.

Throughput in millions of work items/s. Each workload uses its own one-thread run as the speedup baseline.

Workload1 thread2 threads4 threads8 threads4-thread speedup
sparse try_insert (fresh)9.44.43.53.30.38x
sparse try_insert_many (fresh)19.137.372.7119.23.81x
sparse get31.461.0115.8229.23.68x
direct insert (fresh)18.827.846.685.42.48x
direct insert (overwrite)23.635.861.5109.02.60x
direct get15.823.139.972.82.52x
atomic direct insert (fresh)25.047.191.3178.63.66x
hive insert (fresh)19.740.278.2143.63.97x
hive remove6.612.824.748.43.74x
hive churn (64 live per thread)12.621.732.152.82.54x
append hive insert (fresh)22.940.677.2141.23.37x
id allocate (fresh)28.656.4114.7216.54.01x
id free10.119.337.371.23.71x
id churn (64 live per thread)12.621.830.652.12.43x
shared counter fetch_add only141.149.150.251.40.36x

Single-key try_insert into a fresh sparse map does not scale: every insert reserves a dense-array position from one shared counter, so threads contend on it. try_insert_many takes one reservation per batch and scales. The last row is a single shared fetch_add counter, as a reference for cache-line contention.

Python

The Python scaling harness splits 2 million shuffled keys among workers using typed float64 maps and batch calls. The median of seven elapsed wall times includes dispatch, NumPy copies and creation of the returned arrays. Speedup compares the same map and operation against one worker on the same Python build.

Free-threaded CPython 3.14.10 (GIL disabled)

ClassOperationThreadsMedian (s)Throughput (M keys/s)Speedup
ConcurrentDirectMapF64get_many10.19265110.381.00x
ConcurrentDirectMapF64get_many20.11169717.911.72x
ConcurrentDirectMapF64get_many40.06103132.773.16x
ConcurrentDirectMapF64get_many80.03971750.364.85x
ConcurrentDirectMapF64set_many10.11738317.041.00x
ConcurrentDirectMapF64set_many20.08190024.421.43x
ConcurrentDirectMapF64set_many40.04836141.362.43x
ConcurrentDirectMapF64set_many80.02762572.404.25x
ConcurrentSparseMapF64get_many10.10508319.031.00x
ConcurrentSparseMapF64get_many20.05544036.081.90x
ConcurrentSparseMapF64get_many40.03705753.972.84x
ConcurrentSparseMapF64get_many80.02555978.254.11x
ConcurrentSparseMapF64insert_many10.13817314.471.00x
ConcurrentSparseMapF64insert_many20.06285631.822.20x
ConcurrentSparseMapF64insert_many40.03427358.364.03x
ConcurrentSparseMapF64insert_many80.02156992.736.41x

CPython 3.12.16 (GIL enabled)

ClassOperationThreadsMedian (s)Throughput (M keys/s)Speedup
ConcurrentDirectMapF64get_many10.17440511.471.00x
ConcurrentDirectMapF64get_many20.10915418.321.60x
ConcurrentDirectMapF64get_many40.06631830.162.63x
ConcurrentDirectMapF64get_many80.04894740.863.56x
ConcurrentDirectMapF64set_many10.14160114.121.00x
ConcurrentDirectMapF64set_many20.09227621.671.53x
ConcurrentDirectMapF64set_many40.05661935.322.50x
ConcurrentDirectMapF64set_many80.03975950.303.56x
ConcurrentSparseMapF64get_many10.09224721.681.00x
ConcurrentSparseMapF64get_many20.05060439.521.82x
ConcurrentSparseMapF64get_many40.04650543.011.98x
ConcurrentSparseMapF64get_many80.02880769.433.20x
ConcurrentSparseMapF64insert_many10.14212414.071.00x
ConcurrentSparseMapF64insert_many20.06602130.292.15x
ConcurrentSparseMapF64insert_many40.04070649.133.49x
ConcurrentSparseMapF64insert_many80.03612455.373.93x

With the GIL, batch calls still overlap because they release it while in Rust; the free-threaded build also runs the Python-side dispatch in parallel.

Python Queues

The queue harness uses 1 million input items and reports throughput from the median of five wall times. 3.12 is CPython 3.12.16 with the GIL enabled. 3.14t is CPython 3.14.10 with the GIL disabled. Throughput units differ across workloads.

FIFO

Millions of items/s. Each item counts once for a push followed by a pop. The single-thread case fills the queue then drains it. Multi-thread cases use equal numbers of producers and consumers working concurrently. SimpleQueue consumers block in get(). The other consumers retry an empty queue. The batch column uses push_many and pop_many in batches of up to 1,024 items.

CasePythondequeSimpleQueueConcurrentQueueConcurrentQueue batch
1 thread3.1216.2912.246.0512.64
1 thread3.14t8.907.305.2011.75
4 + 4 threads3.123.494.491.816.23
4 + 4 threads3.14t3.493.322.895.58
8 + 8 threads3.123.894.552.196.08
8 + 8 threads3.14t0.420.711.755.62

At 8 producers and 8 consumers on free-threaded CPython, the per-item ConcurrentQueue path processed 1.75 M items/s and the batch path processed 5.62 M items/s. For single-threaded scalar calls, deque led on both builds.

Priority Queues

All runs use distinct integer keys with random float priorities in min-queue mode. PriorityQueueF64 and ConcurrentPriorityQueueF64 update existing keys in place. The concurrent queue’s pop uses relaxed ordering. Use the pop_exact column when comparing global-priority removal with heapq in the single-thread push-and-drain workload.

Push and Drain

Millions of items/s. A single thread pushes all items, then drains the queue. Each item counts once across both phases.

PythonheapqPriorityQueueF64Concurrent popConcurrent pop_exact
3.120.210.700.640.22
3.14t0.230.890.830.24

Update Existing Priorities

Millions of writes/s. The numerator counts the initial n pushes and n/2 priority changes. Elapsed time also includes draining the queue. heapq pushes a new tuple for each change and skips stale tuples during the drain using a dictionary of current priorities.

Pythonheapq + lazy invalidationPriorityQueueF64Concurrent pop
3.120.161.010.92
3.14t0.171.131.01

Shared Queue Across Workers

Millions of calls/s. Workers each push their share of the keys and wait at a barrier before draining the shared queue. Each successful push and pop counts separately. The lock-based heapq baseline uses one shared threading.Lock. The paged queue uses relaxed pop. The one-worker row here uses the same lock-based harness and units as the multi-worker rows.

WorkersPythonheapq + lockConcurrent pop
13.14t0.401.50
43.14t0.174.19
83.120.130.89
83.14t0.155.34

Setup and Reproduction

ItemConfiguration
Machine4 × Intel Xeon E7-8860 v4 at 2.20 GHz (72 cores, 144 hardware threads), 503 GB RAM, Linux 5.15, glibc 2.35
Rust resultsb814a0e, rustc 1.100.0, release mode, no target-cpu flags
Rust timingCriterion 0.5.1 medians from one run. The largest cases use 10 samples and a 3-second measurement target. Different groups ran on separate physical cores. The scaling run used eight physical cores on one NUMA node and ran alone.
LoadOther users idle (load average 0.0 at the start)
Python queue resultsPackage built from 0989af0. The later commit 267f4c3 contains the benchmark script. Runs were pinned to 32 hardware threads with taskset -c 64-95.

From the repository, run the Rust harness with the source revision above to reproduce the Rust setup:

cargo bench -p paged-collections-bench --bench sparse
cargo run --release -p paged-collections-bench --bin memory
cargo run --release -p paged-collections-bench --bin churn
cargo run --release -p paged-collections-bench --bin page_sweep
cargo run --release -p paged-collections-bench --bin concurrent_scaling -- 2000000 7

The other Criterion groups are direct, ids, seq and pq. The largest cases can require tens of GiB. To select a smaller case, pass a Criterion filter, for example -- /1000/.

Run the Python scripts from the repository root with a release build of paged-collections installed in the chosen Python environment:

python benchmarks/python/concurrent_scaling.py --n 2000000 --threads 1 2 4 8 --repeat 7
python benchmarks/python/queues.py --n 1000000 --threads 1 2 4 8 --repeat 5