Skip to content

Commit 684ead6

Browse files
authored
[DI] Add Sirun benchmark for Dynamic Instrumentation (#5004)
1 parent f76beab commit 684ead6

4 files changed

Lines changed: 146 additions & 0 deletions

File tree

benchmark/sirun/debugger/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dynamic Instrumentation Benchmarks
2+
3+
Benchmark the overhead on the instrumented application of different probe configurations.

benchmark/sirun/debugger/app.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict'
2+
3+
// WARNING: CHANGES TO THIS FUNCTION WILL AFFECT THE LINE NUMBERS OF THE BREAKPOINTS
4+
5+
if (process.env.DD_DYNAMIC_INSTRUMENTATION_ENABLED === 'true') {
6+
require('./start-devtools-client')
7+
}
8+
9+
let n = 0
10+
11+
// Give the devtools client time to connect before doing work
12+
setTimeout(doSomeWork, 250)
13+
14+
function doSomeWork (arg1 = 1, arg2 = 2) {
15+
const data = getSomeData()
16+
data.n = n
17+
if (++n <= 500) {
18+
setTimeout(doSomeWork, 1)
19+
}
20+
}
21+
22+
// Location to put dummy breakpoint that is never hit:
23+
// eslint-disable-next-line no-unused-vars
24+
function dummy () {
25+
throw new Error('This line should never execute')
26+
}
27+
28+
function getSomeData () {
29+
const str = 'a'.repeat(1000)
30+
const arr = Array.from({ length: 1000 }, (_, i) => i)
31+
32+
const data = {
33+
foo: 'bar',
34+
nil: null,
35+
undef: undefined,
36+
bool: true
37+
}
38+
data.recursive = data
39+
40+
for (let i = 0; i < 20; i++) {
41+
data[`str${i}`] = str
42+
data[`arr${i}`] = arr
43+
}
44+
45+
return data
46+
}

benchmark/sirun/debugger/meta.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "debugger",
3+
"cachegrind": false,
4+
"iterations": 10,
5+
"instructions": true,
6+
"variants": {
7+
"control": {
8+
"service": "while true; do { echo -e 'HTTP/1.1 202 Accepted\r\n\r\n'; } | nc -l 8080 > /dev/null; done",
9+
"run": "node app.js",
10+
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node app.js\"",
11+
"env": {
12+
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "false"
13+
}
14+
},
15+
"enabled-but-breakpoint-not-hit": {
16+
"service": "while true; do { echo -e 'HTTP/1.1 202 Accepted\r\n\r\n'; } | nc -l 8080 > /dev/null; done",
17+
"run": "node app.js",
18+
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node app.js\"",
19+
"baseline": "control",
20+
"env": {
21+
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "true",
22+
"BREAKPOINT_FILE": "app.js",
23+
"BREAKPOINT_LINE": "25"
24+
}
25+
},
26+
"line-probe-without-snapshot": {
27+
"service": "while true; do { echo -e 'HTTP/1.1 202 Accepted\r\n\r\n'; } | nc -l 8080 > /dev/null; done",
28+
"run": "node app.js",
29+
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node app.js\"",
30+
"baseline": "control",
31+
"env": {
32+
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "true",
33+
"BREAKPOINT_FILE": "app.js",
34+
"BREAKPOINT_LINE": "18"
35+
}
36+
},
37+
"line-probe-with-snapshot-default": {
38+
"service": "while true; do { echo -e 'HTTP/1.1 202 Accepted\r\n\r\n'; } | nc -l 8080 > /dev/null; done",
39+
"run": "node app.js",
40+
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node app.js\"",
41+
"baseline": "line-probe-without-snapshot",
42+
"env": {
43+
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "true",
44+
"BREAKPOINT_FILE": "app.js",
45+
"BREAKPOINT_LINE": "18",
46+
"CAPTURE_SNAPSHOT": "true"
47+
}
48+
},
49+
"line-probe-with-snapshot-minimal": {
50+
"service": "while true; do { echo -e 'HTTP/1.1 202 Accepted\r\n\r\n'; } | nc -l 8080 > /dev/null; done",
51+
"run": "node app.js",
52+
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node app.js\"",
53+
"baseline": "line-probe-without-snapshot",
54+
"env": {
55+
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": "true",
56+
"BREAKPOINT_FILE": "app.js",
57+
"BREAKPOINT_LINE": "18",
58+
"CAPTURE_SNAPSHOT": "true",
59+
"MAX_REFERENCE_DEPTH": "0",
60+
"MAX_COLLECTION_SIZE": "0",
61+
"MAX_FIELD_COUNT": "0",
62+
"MAX_LENGTH": "9007199254740991"
63+
}
64+
}
65+
}
66+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict'
2+
3+
const Config = require('../../../packages/dd-trace/src/config')
4+
const { start } = require('../../../packages/dd-trace/src/debugger')
5+
const { generateProbeConfig } = require('../../../packages/dd-trace/test/debugger/devtools_client/utils')
6+
7+
const breakpoint = {
8+
file: process.env.BREAKPOINT_FILE,
9+
line: process.env.BREAKPOINT_LINE
10+
}
11+
const config = new Config()
12+
const rc = {
13+
setProductHandler (product, cb) {
14+
const action = 'apply'
15+
const conf = generateProbeConfig(breakpoint, {
16+
captureSnapshot: process.env.CAPTURE_SNAPSHOT === 'true',
17+
capture: {
18+
maxReferenceDepth: process.env.MAX_REFERENCE_DEPTH ? parseInt(process.env.MAX_REFERENCE_DEPTH, 10) : undefined,
19+
maxCollectionSize: process.env.MAX_COLLECTION_SIZE ? parseInt(process.env.MAX_COLLECTION_SIZE, 10) : undefined,
20+
maxFieldCount: process.env.MAX_FIELD_COUNT ? parseInt(process.env.MAX_FIELD_COUNT, 10) : undefined,
21+
maxLength: process.env.MAX_LENGTH ? parseInt(process.env.MAX_LENGTH, 10) : undefined
22+
}
23+
})
24+
const id = 'id'
25+
const ack = () => {}
26+
27+
cb(action, conf, id, ack)
28+
}
29+
}
30+
31+
start(config, rc)

0 commit comments

Comments
 (0)