Skip to content

Inconsistent results with MemoryDiagnoser between identical runs with Server GC #1913

Closed
@cmeeren

Description

@cmeeren

The following two results are from two consecutive runs of the exact same code with the exact same BenchmarkDotNet configuration. Notice the differences in Gen 0 (1000 vs 2000 collects per 1k ops) and Gen 1 (0 vs 1000 collects per 1k ops).

I have noticed this a bit in my testing. Is this to be expected? What does it mean? How can I use MemoryDiagnoser effectively to get information (e.g. about GC pressure, I think; note that I know very little about GC) when the results seem to vary so significantly between runs?

(Note that this is from a complex project; unfortunately I don't have a minimal repro.)

It's also interesting to note the differences in the histograms between the runs, though I have no idea if that is relevant here.

Edit: Is it relevant that I am using server GC? Job.Default.WithGcServer(true)

Run 1

// * Detailed results *
Benchmark.GetCollection: Job-QFDCIT(Server=True) [NRes=10, NInc=5]
Runtime = .NET 6.0.1 (6.0.121.56705), X64 RyuJIT; GC = Concurrent Server
Mean = 396.516 μs, StdErr = 1.236 μs (0.31%), N = 14, StdDev = 4.623 μs
Min = 391.917 μs, Q1 = 393.255 μs, Median = 394.960 μs, Q3 = 397.735 μs, Max = 406.730 μs
IQR = 4.480 μs, LowerFence = 386.536 μs, UpperFence = 404.455 μs
ConfidenceInterval = [391.301 μs; 401.731 μs] (CI 99.9%), Margin = 5.215 μs (1.32% of Mean)
Skewness = 0.95, Kurtosis = 2.6, MValue = 2
-------------------- Histogram --------------------
[390.455 μs ; 409.248 μs) | @@@@@@@@@@@@@@
---------------------------------------------------

Benchmark.GetCollection: Job-QFDCIT(Server=True) [NRes=10000, NInc=5]
Runtime = .NET 6.0.1 (6.0.121.56705), X64 RyuJIT; GC = Concurrent Server
Mean = 216.954 ms, StdErr = 1.224 ms (0.56%), N = 46, StdDev = 8.301 ms
Min = 201.155 ms, Q1 = 211.229 ms, Median = 214.586 ms, Q3 = 224.154 ms, Max = 232.700 ms
IQR = 12.925 ms, LowerFence = 191.842 ms, UpperFence = 243.541 ms
ConfidenceInterval = [212.645 ms; 221.262 ms] (CI 99.9%), Margin = 4.308 ms (1.99% of Mean)
Skewness = 0.08, Kurtosis = 1.95, MValue = 2.95
-------------------- Histogram --------------------
[200.762 ms ; 206.843 ms) | @@@@@@
[206.843 ms ; 216.326 ms) | @@@@@@@@@@@@@@@@@@@
[216.326 ms ; 221.689 ms) | @@@@
[221.689 ms ; 227.770 ms) | @@@@@@@@@@@@@
[227.770 ms ; 234.152 ms) | @@@@
---------------------------------------------------

// * Summary *

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1466 (21H1/May2021Update)
Intel Xeon W-2133 CPU 3.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.101
  [Host]     : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DEBUG
  Job-QFDCIT : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT

Server=True  

|        Method |  NRes | NInc |         Mean |       Error |      StdDev |     Gen 0 |     Gen 1 |  Allocated |
|-------------- |------ |----- |-------------:|------------:|------------:|----------:|----------:|-----------:|
| GetCollection |    10 |    5 |     396.5 μs |     5.21 μs |     4.62 μs |   10.7422 |         - |     645 KB |
| GetCollection | 10000 |    5 | 216,953.5 μs | 4,308.46 μs | 8,300.94 μs | 2000.0000 | 1000.0000 | 579,511 KB |

// * Warnings *
MultimodalDistribution
  Benchmark.GetCollection: Server=True -> It seems that the distribution can have several modes (mValue = 2.95)

// * Hints *
Outliers
  Benchmark.GetCollection: Server=True -> 1 outlier  was  removed (426.98 μs)
  Benchmark.GetCollection: Server=True -> 1 outlier  was  removed (244.82 ms)

Run 2

// * Detailed results *
Benchmark.GetCollection: Job-RLRTSB(Server=True) [NRes=10, NInc=5]
Runtime = .NET 6.0.1 (6.0.121.56705), X64 RyuJIT; GC = Concurrent Server
Mean = 397.049 μs, StdErr = 0.607 μs (0.15%), N = 13, StdDev = 2.187 μs
Min = 392.965 μs, Q1 = 396.024 μs, Median = 397.393 μs, Q3 = 398.576 μs, Max = 400.836 μs
IQR = 2.552 μs, LowerFence = 392.196 μs, UpperFence = 402.404 μs
ConfidenceInterval = [394.429 μs; 399.668 μs] (CI 99.9%), Margin = 2.620 μs (0.66% of Mean)
Skewness = -0.26, Kurtosis = 2.09, MValue = 2
-------------------- Histogram --------------------
[391.744 μs ; 402.057 μs) | @@@@@@@@@@@@@
---------------------------------------------------

Benchmark.GetCollection: Job-RLRTSB(Server=True) [NRes=10000, NInc=5]
Runtime = .NET 6.0.1 (6.0.121.56705), X64 RyuJIT; GC = Concurrent Server
Mean = 216.102 ms, StdErr = 1.171 ms (0.54%), N = 35, StdDev = 6.929 ms
Min = 200.511 ms, Q1 = 210.869 ms, Median = 216.615 ms, Q3 = 219.552 ms, Max = 231.583 ms
IQR = 8.682 ms, LowerFence = 197.846 ms, UpperFence = 232.575 ms
ConfidenceInterval = [211.885 ms; 220.319 ms] (CI 99.9%), Margin = 4.217 ms (1.95% of Mean)
Skewness = -0.01, Kurtosis = 2.71, MValue = 2
-------------------- Histogram --------------------
[200.134 ms ; 208.088 ms) | @@@
[208.088 ms ; 214.659 ms) | @@@@@@@@@@@
[214.659 ms ; 220.219 ms) | @@@@@@@@@@@@@@
[220.219 ms ; 226.285 ms) | @@@@@
[226.285 ms ; 233.172 ms) | @@
---------------------------------------------------

// * Summary *

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1466 (21H1/May2021Update)
Intel Xeon W-2133 CPU 3.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.101
  [Host]     : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DEBUG
  Job-RLRTSB : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT

Server=True  

|        Method |  NRes | NInc |         Mean |       Error |      StdDev |     Gen 0 |  Allocated |
|-------------- |------ |----- |-------------:|------------:|------------:|----------:|-----------:|
| GetCollection |    10 |    5 |     397.0 μs |     2.62 μs |     2.19 μs |   10.7422 |     644 KB |
| GetCollection | 10000 |    5 | 216,102.0 μs | 4,217.06 μs | 6,928.75 μs | 1000.0000 | 579,424 KB |

// * Hints *
Outliers
  Benchmark.GetCollection: Server=True -> 2 outliers were removed (404.49 μs, 411.06 μs)
  Benchmark.GetCollection: Server=True -> 2 outliers were removed (233.20 ms, 234.78 ms)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions