Skip to content

Commit 1b95dcd

Browse files
BridgeARpabloerhard
authored andcommitted
bench(sirun): report operations per second (#9039)
Loop benchmarks now emit an operations-per-second metric from the same measured-loop window that the startup guard already owns, without adding a second timer around each benchmark. Bench variants now use OPERATIONS as loop-count input, so the startup guard reports throughput from the same counter each benchmark already runs with.
1 parent 61c60dc commit 1b95dcd

79 files changed

Lines changed: 249 additions & 212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmark/sirun/child_process/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require('../../../packages/datadog-instrumentations/src/child_process')
1818
const channel = dc.tracingChannel('datadog:child_process:execution')
1919

2020
const { VARIANT } = process.env
21-
const ITERATIONS = Number(process.env.ITERATIONS) || 5_000_000
21+
const OPERATIONS = Number(process.env.OPERATIONS)
2222

2323
// execFile-shaped (file + array args) vs exec-shaped (single shell string).
2424
const useFileArgs = VARIANT === 'file-args'
@@ -91,7 +91,7 @@ assert.ok(probeContext.abortController, 'context is missing the AbortController'
9191

9292
let sink = 0
9393
guard.loopStart()
94-
for (let i = 0; i < ITERATIONS; i++) {
94+
for (let i = 0; i < OPERATIONS; i++) {
9595
sink += instrumentedCall()
9696
}
9797
guard.done()

benchmark/sirun/child_process/meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"instructions": true,
88
"variants": {
99
"shell-string": {
10-
"env": { "VARIANT": "shell-string", "ITERATIONS": "1100000" }
10+
"env": { "VARIANT": "shell-string", "OPERATIONS": "1100000" }
1111
},
1212
"file-args": {
13-
"env": { "VARIANT": "file-args", "ITERATIONS": "1000000" }
13+
"env": { "VARIANT": "file-args", "OPERATIONS": "1000000" }
1414
}
1515
}
1616
}

benchmark/sirun/collect-overview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function categoryOf (name) {
5454
}
5555

5656
function innerCount (env = {}) {
57-
return env.COUNT || env.ITERATIONS || env.QUERIES || (env.REQS ? `${env.REQS} reqs` : '-')
57+
return env.OPERATIONS || env.COUNT || (env.REQS ? `${env.REQS} reqs` : '-')
5858
}
5959

6060
function stats (times) {

benchmark/sirun/datastreams/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { getMessageSize } = require('../../../packages/dd-trace/src/datastreams/s
1414

1515
const { VARIANT } = process.env
1616

17-
const ITERATIONS = 1_200_000
17+
const OPERATIONS = Number(process.env.OPERATIONS)
1818

1919
const processor = new DataStreamsProcessor({
2020
dsmEnabled: true,
@@ -107,13 +107,13 @@ assert.ok(CONSUME_CARRIERS[0]['dd-pathway-ctx-base64'], 'codec did not inject pa
107107

108108
guard.loopStart()
109109
if (VARIANT === 'consume') {
110-
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
110+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
111111
const carrier = CONSUME_CARRIERS[iteration % CONSUME_CARRIERS.length]
112112
const ctx = DsmPathwayCodec.decode(carrier)
113113
processor.setCheckpoint(CONSUMER_TAGS[iteration % CONSUMER_TAGS.length], span, ctx, MESSAGE_SIZE)
114114
}
115115
} else if (VARIANT === 'produce-with-message-size') {
116-
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
116+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
117117
const payloadSize = getMessageSize(MESSAGE)
118118
const ctx = processor.setCheckpoint(
119119
PRODUCER_TAGS[iteration % PRODUCER_TAGS.length],
@@ -124,7 +124,7 @@ if (VARIANT === 'consume') {
124124
DsmPathwayCodec.encode(ctx, {})
125125
}
126126
} else if (VARIANT === 'produce-manual-checkpoint') {
127-
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
127+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
128128
const ctx = processor.setCheckpoint(
129129
MANUAL_PRODUCER_TAGS[iteration % MANUAL_PRODUCER_TAGS.length],
130130
span,
@@ -134,7 +134,7 @@ if (VARIANT === 'consume') {
134134
DsmPathwayCodec.encode(ctx, {})
135135
}
136136
} else if (VARIANT === 'produce-high-cardinality') {
137-
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
137+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
138138
const ctx = processor.setCheckpoint(
139139
HIGH_CARDINALITY_PRODUCER_TAGS[iteration % HIGH_CARDINALITY_PRODUCER_TAGS.length],
140140
span,
@@ -144,7 +144,7 @@ if (VARIANT === 'consume') {
144144
DsmPathwayCodec.encode(ctx, {})
145145
}
146146
} else {
147-
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
147+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
148148
const ctx = processor.setCheckpoint(
149149
PRODUCER_TAGS[iteration % PRODUCER_TAGS.length],
150150
span,

benchmark/sirun/datastreams/meta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"iterations": 20,
77
"instructions": true,
88
"variants": {
9-
"produce": { "env": { "VARIANT": "produce" } },
10-
"consume": { "env": { "VARIANT": "consume" } },
11-
"produce-with-message-size": { "env": { "VARIANT": "produce-with-message-size" } },
12-
"produce-manual-checkpoint": { "env": { "VARIANT": "produce-manual-checkpoint" } },
13-
"produce-high-cardinality": { "env": { "VARIANT": "produce-high-cardinality" } }
9+
"produce": { "env": { "VARIANT": "produce", "OPERATIONS": "1200000" } },
10+
"consume": { "env": { "VARIANT": "consume", "OPERATIONS": "1200000" } },
11+
"produce-with-message-size": { "env": { "VARIANT": "produce-with-message-size", "OPERATIONS": "1200000" } },
12+
"produce-manual-checkpoint": { "env": { "VARIANT": "produce-manual-checkpoint", "OPERATIONS": "1200000" } },
13+
"produce-high-cardinality": { "env": { "VARIANT": "produce-high-cardinality", "OPERATIONS": "1200000" } }
1414
}
1515
}

benchmark/sirun/debugger/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const guard = require('../startup-guard')
88

9-
const ITERATIONS = Number(process.env.ITERATIONS) || 5000
9+
const OPERATIONS = Number(process.env.OPERATIONS)
1010

1111
if (process.env.DD_DYNAMIC_INSTRUMENTATION_ENABLED === 'true') {
1212
// The devtools worker and its ports are unref'd, so nothing holds the event
@@ -26,7 +26,7 @@ if (process.env.DD_DYNAMIC_INSTRUMENTATION_ENABLED === 'true') {
2626

2727
function runWork () {
2828
guard.loopStart()
29-
for (let i = 0; i < ITERATIONS; i++) {
29+
for (let i = 0; i < OPERATIONS; i++) {
3030
doSomeWork(i)
3131
}
3232
guard.done(0.35)

benchmark/sirun/debugger/meta.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "true",
2626
"BREAKPOINT_FILE": "app.js",
2727
"BREAKPOINT_LINE": "37",
28-
"ITERATIONS": "3500"
28+
"OPERATIONS": "3500"
2929
}
3030
},
3131
"line-probe-with-snapshot-default": {
@@ -40,7 +40,7 @@
4040
"BREAKPOINT_LINE": "37",
4141
"CAPTURE_SNAPSHOT": "true",
4242
"MAX_SNAPSHOTS_PER_SECOND_GLOBALLY": "1000000",
43-
"ITERATIONS": "2450"
43+
"OPERATIONS": "2450"
4444
}
4545
},
4646
"line-probe-with-snapshot-minimal": {
@@ -59,7 +59,7 @@
5959
"MAX_COLLECTION_SIZE": "0",
6060
"MAX_FIELD_COUNT": "0",
6161
"MAX_LENGTH": "9007199254740991",
62-
"ITERATIONS": "3500"
62+
"OPERATIONS": "3500"
6363
}
6464
}
6565
}

benchmark/sirun/dogstatsd/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const guard = require('../startup-guard')
66
const { DogStatsDClient, MetricsAggregationClient } = require('../../../packages/dd-trace/src/dogstatsd')
77

88
const { VARIANT } = process.env
9-
const ITERATIONS = Number(process.env.ITERATIONS) || 5_000_000
9+
const OPERATIONS = Number(process.env.OPERATIONS)
1010

1111
// Every metric the tracer emits (runtime metrics, custom metrics) runs through
1212
// DogStatsDClient._add: build the `stat:value|type` line, splice the global and
@@ -48,7 +48,7 @@ if (VARIANT === 'aggregated') {
4848
// The runtime-metrics path: accumulate into the tag tree, then flush walks the
4949
// tree and formats every node through the client. Stubbed socket on flush.
5050
const agg = new MetricsAggregationClient(client)
51-
for (let i = 0; i < ITERATIONS; i++) {
51+
for (let i = 0; i < OPERATIONS; i++) {
5252
agg.count(NAME, 1, FEW_TAGS)
5353
agg.gauge('runtime.node.mem.heap_used', i, FEW_TAGS)
5454
if ((i & 0x3FF) === 0) agg.flush()
@@ -57,7 +57,7 @@ if (VARIANT === 'aggregated') {
5757
} else {
5858
const tags = VARIANT === 'no-tags' ? undefined : (VARIANT === 'many-tags' ? MANY_TAGS : FEW_TAGS)
5959
const type = VARIANT === 'no-tags' ? 'c' : 'g'
60-
for (let i = 0; i < ITERATIONS; i++) {
60+
for (let i = 0; i < OPERATIONS; i++) {
6161
client._add(NAME, i, type, tags)
6262
// Drain the datagram queue without sending so memory stays flat.
6363
if ((i & 0x7FF) === 0) client._queue.length = 0

benchmark/sirun/dogstatsd/meta.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"instructions": true,
88
"variants": {
99
"no-tags": {
10-
"env": { "VARIANT": "no-tags", "ITERATIONS": "6000000" }
10+
"env": { "VARIANT": "no-tags", "OPERATIONS": "6000000" }
1111
},
1212
"with-tags": {
13-
"env": { "VARIANT": "with-tags", "ITERATIONS": "8300000" }
13+
"env": { "VARIANT": "with-tags", "OPERATIONS": "8300000" }
1414
},
1515
"many-tags": {
16-
"env": { "VARIANT": "many-tags", "ITERATIONS": "3000000" }
16+
"env": { "VARIANT": "many-tags", "OPERATIONS": "3000000" }
1717
},
1818
"aggregated": {
19-
"env": { "VARIANT": "aggregated", "ITERATIONS": "15000000" }
19+
"env": { "VARIANT": "aggregated", "OPERATIONS": "15000000" }
2020
}
2121
}
2222
}

benchmark/sirun/encoding/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
} = process.env
1111

1212
const WIDE_TAGS = Number(process.env.WIDE_TAGS) || 0
13-
const ENCODE_COUNT = Number(process.env.ENCODE_COUNT) || 5000
13+
const OPERATIONS = Number(process.env.OPERATIONS)
1414

1515
const { AgentEncoder } = require(`../../../packages/dd-trace/src/encode/${ENCODER_VERSION}`)
1616
const { buildTrace, tickTrace, attachFreshEvents } = require('./trace-fixture')
@@ -43,12 +43,12 @@ encoder._reset()
4343

4444
guard.loopStart()
4545
if (WITH_SPAN_EVENTS === 'none') {
46-
for (let iteration = 0; iteration < ENCODE_COUNT; iteration++) {
46+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
4747
tickTrace(trace, iteration)
4848
encoder.encode(trace)
4949
}
5050
} else {
51-
for (let iteration = 0; iteration < ENCODE_COUNT; iteration++) {
51+
for (let iteration = 0; iteration < OPERATIONS; iteration++) {
5252
tickTrace(trace, iteration)
5353
attachFreshEvents(trace, iteration)
5454
encoder.encode(trace)

0 commit comments

Comments
 (0)