Skip to content

Commit

Permalink
Align benchmark scaling and minimum samples (#2839)
Browse files Browse the repository at this point in the history
# Motivation

We want to have an aligned strategy across all of our benchmarks in how
we use the scaling factor and samples.

# Modification

This PR makes sure that any inner loop is scaled by the scaling factor.
Moreover, we want to run more than 1 iteration. To do this we set an
almost infinite maximum duration and a maximum iteration count.

# Result

More consistent benchmarks
  • Loading branch information
FranzBusch committed Aug 15, 2024
1 parent 286834d commit e59009d
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 27 deletions.
7 changes: 6 additions & 1 deletion Benchmarks/Benchmarks/NIOCoreBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ let benchmarks = {

Benchmark(
"NIOAsyncChannel.init",
configuration: Benchmark.Configuration(metrics: defaultMetrics)
configuration: .init(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
// Elide the cost of the 'EmbeddedChannel'. It's only used for its pipeline.
var channels: [EmbeddedChannel] = []
Expand Down
8 changes: 5 additions & 3 deletions Benchmarks/Benchmarks/NIOPosixBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ let benchmarks = {
"TCPEcho",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .milliseconds,
scalingFactor: .mega
scalingFactor: .mega,
maxDuration: .seconds(10_000_000),
maxIterations: 5
)
) { benchmark in
try runTCPEcho(
Expand All @@ -43,8 +44,9 @@ let benchmarks = {
"TCPEchoAsyncChannel",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .milliseconds,
scalingFactor: .mega,
maxDuration: .seconds(10_000_000),
maxIterations: 5,
// We are expecting a bit of allocation variance due to an allocation
// in the Concurrency runtime which happens when resuming a continuation.
thresholds: [.mallocCountTotal: .init(absolute: [.p90: 2000])],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 555
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164375
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
"mallocCountTotal" : 556
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
"mallocCountTotal" : 556
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 164000
}
"mallocCountTotal" : 164381
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 548
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164376
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 8
}
"mallocCountTotal" : 8000
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
"mallocCountTotal" : 548
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164371
}

0 comments on commit e59009d

Please sign in to comment.