Skip to content

refactor: expose the position of a record with the type it is stored in - #1019

Merged
vbreuss merged 1 commit into
mainfrom
refactor/record-position-as-int
Nov 18, 2026
Merged

vbreuss merged 1 commit into
mainfrom
refactor/record-position-as-int

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 18, 2026

Copy link
Copy Markdown
Member

The position of a record is stored in 32 bits, but the property was still a long from the time it was drawn from a shared counter, so every reader cast it back.

@vbreuss vbreuss self-assigned this Nov 18, 2026
@vbreuss
vbreuss added this pull request to stack #1018 November 18, 2026 10:13
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Test Results

    47 files  ±0      47 suites  ±0   1h 1m 8s ⏱️ - 1m 19s
 4 813 tests ±0   4 813 ✅ ±0  0 💤 ±0  0 ❌ ±0 
48 555 runs  ±0  48 555 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit b92a56f. ± Comparison against base commit 415ffae.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main @​ 3ef709c6: memory to the latest run, time to the median of the last 10 runs, as the runners differ in speed. A relative change marks when Mockolate gets more than 15% faster or slower relative to Imposter and TUnitMocks: 🔴 / 🟢 against both of them, 🔸 / 🔹 against only one.

CallbackBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Callback 0.90× → 1.09× 🟢 -17% 2.23× → 2.73× 🟢 -18%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Callback 208.6 ns → 117.0 ns (-44%) 792 B → 792 B 0.90× → 1.09× 🟢 -17% 2.23× → 2.73× 🟢 -18%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.52GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 117.0 ns 5.53 ns 5.18 ns 1.00 792 B 1.00
Imposter 127.2 ns 1.24 ns 1.16 ns 1.09 616 B 0.78
TUnitMocks 319.6 ns 14.14 ns 13.22 ns 2.74 2056 B 2.60
Moq 29,255.4 ns 285.79 ns 267.33 ns 250.40 9055 B 11.43
NSubstitute 2,239.7 ns 89.26 ns 83.49 ns 19.17 7864 B 9.93
FakeItEasy 2,163.8 ns 42.20 ns 35.24 ns 18.52 6930 B 8.75

CompleteEventBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Event 159.0 ns → 148.1 ns (-7%) 696 B → 696 B 1.06× → 1.16× 1.05× → 1.07×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.24GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 148.1 ns 3.54 ns 3.31 ns 1.00 696 B 1.00
Imposter 172.1 ns 1.96 ns 1.73 ns 1.16 512 B 0.74
TUnitMocks 159.1 ns 1.60 ns 1.50 ns 1.08 1392 B 2.00
Moq 15,046.3 ns 153.05 ns 143.16 ns 101.66 12761 B 18.33
NSubstitute 5,527.9 ns 23.10 ns 19.29 ns 37.35 9192 B 13.21
FakeItEasy 224,476.8 ns 838.02 ns 654.27 ns 1,516.70 15618 B 22.44

CompleteIndexerBenchmarks

Memory

Benchmark main PR Δ
Indexer (N=1000) 105,545 B 105,544 B 🟢 -1 B (±0%)

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Indexer (N=1) 0.53× → 0.71× 🟢 -26% 1.36× → 1.85× 🟢 -27%
Indexer (N=10) 0.36× → 0.53× 🟢 -32% 1.19× → 2.10× 🟢 -44%
Indexer (N=1000) 0.28× → 0.46× 🟢 -39% 1.12× → 2.14× 🟢 -48%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Indexer (N=1) 458.6 ns → 283.0 ns (-38%) 1,648 B → 1,648 B 0.53× → 0.71× 🟢 -26% 1.36× → 1.85× 🟢 -27%
Indexer (N=10) 1.62 μs → 833.5 ns (-49%) 2,584 B → 2,584 B 0.36× → 0.53× 🟢 -32% 1.19× → 2.10× 🟢 -44%
Indexer (N=1000) 124.61 μs → 62.93 μs (-50%) 105,545 B → 105,544 B 0.28× → 0.46× 🟢 -39% 1.12× → 2.14× 🟢 -48%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.53GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 283.0 ns 7.51 ns 7.02 ns 1.00 1.61 KB 1.00
Imposter 1 202.1 ns 7.59 ns 7.10 ns 0.71 1.07 KB 0.67
TUnitMocks 1 523.3 ns 31.11 ns 29.10 ns 1.85 2.72 KB 1.69
Moq 1 68,593.3 ns 295.62 ns 262.06 ns 242.50 20.32 KB 12.63
NSubstitute 1 5,202.6 ns 164.77 ns 154.12 ns 18.39 12.78 KB 7.94
FakeItEasy 1 5,318.2 ns 176.65 ns 165.24 ns 18.80 13.27 KB 8.25
Mockolate 10 833.5 ns 22.70 ns 21.23 ns 1.00 2.52 KB 1.00
Imposter 10 440.9 ns 9.12 ns 8.53 ns 0.53 2.13 KB 0.84
TUnitMocks 10 1,754.3 ns 87.33 ns 81.69 ns 2.11 5.37 KB 2.13
Moq 10 70,850.5 ns 2,520.40 ns 2,357.58 ns 85.05 29.69 KB 11.77
NSubstitute 10 13,736.6 ns 346.53 ns 324.14 ns 16.49 25.58 KB 10.14
FakeItEasy 10 11,424.8 ns 158.42 ns 132.29 ns 13.71 32.47 KB 12.87
Mockolate 1000 62,927.3 ns 1,784.80 ns 1,669.51 ns 1.00 103.07 KB 1.00
Imposter 1000 28,648.2 ns 846.87 ns 750.73 ns 0.46 118.15 KB 1.15
TUnitMocks 1000 134,558.9 ns 3,235.99 ns 3,026.95 ns 2.14 293.67 KB 2.85
Moq 1000 517,244.9 ns 12,641.58 ns 11,206.43 ns 8.23 1006.45 KB 9.76
NSubstitute 1000 939,496.3 ns 26,590.61 ns 24,872.87 ns 14.94 1465.64 KB 14.22
FakeItEasy 1000 818,112.4 ns 25,033.50 ns 23,416.35 ns 13.01 2153 KB 20.89

CompleteMethodBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Method (N=10) 0.90× → 0.99× 3.30× → 3.92× 🔹 -16%
Method (N=1000) 0.77× → 0.81× 3.59× → 4.34× 🔹 -17%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Method (N=1) 125.7 ns → 157.7 ns (+25%) 600 B → 600 B 1.13× → 1.17× 2.93× → 3.20×
Method (N=10) 325.2 ns → 360.1 ns (+11%) 1,104 B → 1,104 B 0.90× → 0.99× 3.30× → 3.92× 🔹 -16%
Method (N=1000) 22.51 μs → 24.63 μs (+9%) 56,544 B → 56,544 B 0.77× → 0.81× 3.59× → 4.34× 🔹 -17%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6973P-C 3.56GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 157.7 ns 1.62 ns 1.52 ns 1.00 600 B 1.00
Imposter 1 184.2 ns 2.04 ns 1.90 ns 1.17 728 B 1.21
TUnitMocks 1 504.0 ns 7.02 ns 6.22 ns 3.20 2088 B 3.48
Moq 1 76,220.2 ns 1,455.25 ns 1,361.24 ns 483.35 14906 B 24.84
NSubstitute 1 4,799.7 ns 59.48 ns 55.64 ns 30.44 9320 B 15.53
FakeItEasy 1 3,954.6 ns 41.52 ns 38.84 ns 25.08 8153 B 13.59
Mockolate 10 360.1 ns 5.42 ns 5.07 ns 1.00 1104 B 1.00
Imposter 10 357.1 ns 4.80 ns 4.49 ns 0.99 1088 B 0.99
TUnitMocks 10 1,410.6 ns 13.85 ns 12.95 ns 3.92 3840 B 3.48
Moq 10 78,377.9 ns 1,297.34 ns 1,213.53 ns 217.70 18883 B 17.10
NSubstitute 10 7,027.5 ns 52.88 ns 49.46 ns 19.52 12344 B 11.18
FakeItEasy 10 6,988.3 ns 26.30 ns 23.31 ns 19.41 16391 B 14.85
Mockolate 1000 24,626.7 ns 241.91 ns 226.28 ns 1.00 56544 B 1.00
Imposter 1000 19,945.3 ns 45.96 ns 42.99 ns 0.81 40688 B 0.72
TUnitMocks 1000 106,817.5 ns 282.93 ns 264.65 ns 4.34 203584 B 3.60
Moq 1000 258,359.6 ns 2,417.13 ns 2,142.72 ns 10.49 431907 B 7.64
NSubstitute 1000 207,811.5 ns 2,021.46 ns 1,791.97 ns 8.44 378018 B 6.69
FakeItEasy 1000 330,678.2 ns 2,127.86 ns 1,990.40 ns 13.43 944522 B 16.70

CompletePropertyBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Property (N=1) 241.1 ns → 264.6 ns (+10%) 904 B → 904 B 0.62× → 0.67× 1.63× → 1.60×
Property (N=10) 601.5 ns → 598.1 ns (-1%) 1,768 B → 1,768 B 0.50× → 0.55× 2.39× → 2.57×
Property (N=1000) 43.27 μs → 38.79 μs (-10%) 96,808 B → 96,808 B 0.37× → 0.43× 2.59× → 2.98×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.00GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 264.6 ns 4.78 ns 4.23 ns 1.00 904 B 1.00
Imposter 1 176.3 ns 5.92 ns 5.54 ns 0.67 672 B 0.74
TUnitMocks 1 423.6 ns 5.11 ns 4.78 ns 1.60 1672 B 1.85
Moq 1 11,001.9 ns 37.76 ns 29.48 ns 41.58 10457 B 11.57
NSubstitute 1 7,885.6 ns 40.82 ns 38.18 ns 29.80 11664 B 12.90
FakeItEasy 1 7,712.9 ns 93.58 ns 87.54 ns 29.15 11196 B 12.38
Mockolate 10 598.1 ns 4.96 ns 4.64 ns 1.00 1768 B 1.00
Imposter 10 328.0 ns 5.78 ns 4.51 ns 0.55 960 B 0.54
TUnitMocks 10 1,537.0 ns 21.27 ns 19.89 ns 2.57 4024 B 2.28
Moq 10 17,466.5 ns 144.95 ns 135.58 ns 29.21 17385 B 9.83
NSubstitute 10 17,139.2 ns 322.17 ns 301.35 ns 28.66 21529 B 12.18
FakeItEasy 10 18,926.7 ns 149.11 ns 139.48 ns 31.65 30785 B 17.41
Mockolate 1000 38,788.9 ns 495.46 ns 413.73 ns 1.00 96808 B 1.00
Imposter 1000 16,495.7 ns 156.29 ns 138.55 ns 0.43 32641 B 0.34
TUnitMocks 1000 115,477.1 ns 1,047.72 ns 980.04 ns 2.98 242489 B 2.50
Moq 1000 682,557.3 ns 5,320.68 ns 4,443.01 ns 17.60 724510 B 7.48
NSubstitute 1000 1,033,336.0 ns 11,515.74 ns 10,771.83 ns 26.64 1139703 B 11.77
FakeItEasy 1000 1,338,386.3 ns 20,968.03 ns 18,587.61 ns 34.51 2194290 B 22.67

CompleteUnconfiguredBenchmarks

Memory

Benchmark main PR Δ
Unconfigured (N=1000) 273,265 B 273,264 B 🟢 -1 B (±0%)

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Unconfigured (N=1) 0.44× → 0.63× 🟢 -30% 0.91× → 1.30× 🟢 -30%
Unconfigured (N=10) 0.45× → 0.59× 🟢 -24% 1.50× → 2.03× 🟢 -26%
Unconfigured (N=1000) 0.44× → 0.59× 🟢 -26% 1.70× → 2.34× 🟢 -27%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Unconfigured (N=1) 543.9 ns → 283.4 ns (-48%) 1,512 B → 1,512 B 0.44× → 0.63× 🟢 -30% 0.91× → 1.30× 🟢 -30%
Unconfigured (N=10) 2.12 μs → 1.17 μs (-45%) 3,984 B → 3,984 B 0.45× → 0.59× 🟢 -24% 1.50× → 2.03× 🟢 -26%
Unconfigured (N=1000) 166.95 μs → 96.33 μs (-42%) 273,265 B → 273,264 B 0.44× → 0.59× 🟢 -26% 1.70× → 2.34× 🟢 -27%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.14GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 283.4 ns 6.76 ns 5.99 ns 1.00 1.48 KB 1.00
Imposter 1 179.6 ns 5.30 ns 4.96 ns 0.63 1.06 KB 0.72
TUnitMocks 1 368.7 ns 6.27 ns 5.55 ns 1.30 1.81 KB 1.23
Moq 1 33,440.5 ns 818.88 ns 765.98 ns 118.03 9.8 KB 6.63
NSubstitute 1 4,141.5 ns 57.77 ns 48.24 ns 14.62 10.17 KB 6.89
FakeItEasy 1 4,055.5 ns 104.07 ns 92.25 ns 14.31 11.58 KB 7.84
Mockolate 10 1,165.2 ns 21.25 ns 18.84 ns 1.00 3.89 KB 1.00
Imposter 10 684.2 ns 5.80 ns 4.53 ns 0.59 2.89 KB 0.74
TUnitMocks 10 2,360.5 ns 29.01 ns 25.72 ns 2.03 8.47 KB 2.18
Moq 10 41,783.6 ns 1,186.61 ns 1,109.96 ns 35.87 24.53 KB 6.30
NSubstitute 10 13,542.1 ns 102.78 ns 85.82 ns 11.62 25.06 KB 6.44
FakeItEasy 10 16,550.7 ns 203.55 ns 180.44 ns 14.21 53.92 KB 13.86
Mockolate 1000 96,326.4 ns 1,130.07 ns 943.66 ns 1.00 266.86 KB 1.00
Imposter 1000 57,188.8 ns 338.51 ns 300.08 ns 0.59 203.99 KB 0.76
TUnitMocks 1000 225,877.7 ns 2,567.91 ns 2,144.32 ns 2.35 691.21 KB 2.59
Moq 1000 880,486.1 ns 15,623.00 ns 14,613.76 ns 9.14 1653 KB 6.19
NSubstitute 1000 1,061,968.8 ns 18,626.44 ns 15,553.92 ns 11.03 1653.22 KB 6.20
FakeItEasy 1000 1,828,472.4 ns 57,380.95 ns 50,866.72 ns 18.98 4690.79 KB 17.58

CompleteWorkflowBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Complete 999.8 ns → 679.0 ns (-32%) 2,872 B → 2,872 B 0.92× → 1.04× 2.86× → 3.01×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.15GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 679.0 ns 17.83 ns 14.89 ns 1.00 2.8 KB 1.00
Imposter 703.4 ns 13.87 ns 11.59 ns 1.04 3.17 KB 1.13
TUnitMocks 2,046.8 ns 63.37 ns 52.92 ns 3.02 10.3 KB 3.67
Moq 163,610.0 ns 4,042.64 ns 3,781.48 ns 241.08 46.43 KB 16.55
NSubstitute 13,431.1 ns 241.17 ns 225.59 ns 19.79 37.13 KB 13.24
FakeItEasy 12,821.4 ns 421.73 ns 394.49 ns 18.89 34.34 KB 12.24

MockCreationBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
CreateMock 5.49× → 6.63× 🔹 -17% 1.64× → 1.81×
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
CreateMock 15.7 ns → 9.2 ns (-41%) 136 B → 136 B 5.49× → 6.63× 🔹 -17% 1.64× → 1.81×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.52GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 9.202 ns 0.4773 ns 0.4231 ns 1.00 136 B 1.00
Imposter 61.024 ns 6.0554 ns 5.6643 ns 6.64 504 B 3.71
TUnitMocks 16.696 ns 0.7620 ns 0.7128 ns 1.82 216 B 1.59
Moq 781.187 ns 33.7875 ns 29.9517 ns 85.05 2088 B 15.35
NSubstitute 1,031.855 ns 72.6309 ns 67.9389 ns 112.34 5032 B 37.00
FakeItEasy 954.523 ns 44.6338 ns 41.7505 ns 103.92 2755 B 20.26

@vbreuss
vbreuss force-pushed the refactor/record-position-as-int branch 4 times, most recently from 421bf34 to 5302556 Compare November 18, 2026 13:28
Base automatically changed from refactor/single-consume-all to main November 18, 2026 13:29
The position of a record is stored in 32 bits, but the property was still a `long` from the time it was drawn from a shared counter, so every reader cast it back.
@vbreuss
vbreuss force-pushed the refactor/record-position-as-int branch from 5302556 to 4ed93a6 Compare November 18, 2026 13:29
@vbreuss
vbreuss merged commit 7467af5 into main Nov 18, 2026
20 checks passed
@vbreuss
vbreuss deleted the refactor/record-position-as-int branch November 18, 2026 13:29
@sonarqubecloud

Copy link
Copy Markdown

github-actions Bot added a commit that referenced this pull request Nov 18, 2026
…rd with the type it is stored in (#1019) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
…rd with the type it is stored in (#1019) by Valentin Breuß
@github-actions

Copy link
Copy Markdown

This is addressed in release v4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant