Skip to content

Commit 3eff48b

Browse files
authored
Improve shimmer instrumentation performance (#5593)
* Improve shimmer instrumentation performance The following improvements are implemented: 1. The prototype has to only be looked up in case the constructor is not identical. That is a rare case, so it'll be faster in average. 2. Copying the property descriptors is now done by skipping entries that may not be set. There is also no try / catch needed anymore. 4. The assertions are now faster by preventing duplicated lookups in the positive case. 5. Reusing the existing descriptor instead of creating a new object. * Minor benchmark improvements * Remove outdated benchmarks * Fix basic benchmarks These are now possible to run again and the benchmark script is also fixed. * Fast path for enumerable, writable, configurable properties * Improve shimmer.wrap performance and add TODO entry The wrap performance now has an additional fast path and the noAssert argument is removed due to always being false. Non configurable but writable properties are now instrumented properly.
1 parent d8a536f commit 3eff48b

File tree

11 files changed

+183
-415
lines changed

11 files changed

+183
-415
lines changed

benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Benchmark = require('benchmark')
66
const nock = require('nock')
77

88
Benchmark.options.maxTime = 0
9-
Benchmark.options.minSamples = 5
9+
Benchmark.options.minSamples = 100
1010

1111
nock.disableNetConnect()
1212

benchmark/e2e/README.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

benchmark/e2e/benchmark-run.js

Lines changed: 0 additions & 217 deletions
This file was deleted.

benchmark/e2e/express-helloworld-manyroutes/app.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

benchmark/e2e/fake-agent.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

benchmark/e2e/preamble.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

benchmark/stubs/span.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ const id = require('../../packages/dd-trace/src/id')
44

55
const spanId = id('1234567812345678')
66

7+
const tags = {
8+
'resource.name': '/resource',
9+
'service.name': 'benchmark',
10+
'span.type': 'web',
11+
error: true
12+
}
13+
714
const span = {
815
tracer: () => ({
916
scope: () => ({
@@ -12,27 +19,27 @@ const span = {
1219
_service: 'service'
1320
}),
1421
addTags: () => {},
22+
_addTags: () => {},
1523
context: () => ({
1624
_traceId: spanId,
1725
_spanId: spanId,
1826
_parentId: spanId,
1927
_trace: {
2028
started: [span, span],
21-
finished: [span, span]
22-
},
23-
_tags: {
24-
'resource.name': '/resource',
25-
'service.name': 'benchmark',
26-
'span.type': 'web',
27-
error: true
29+
finished: [span, span],
30+
tags
2831
},
32+
_tags: tags,
2933
_sampling: {},
3034
_name: 'operation'
3135
}),
3236
_startTime: 1500000000000.123,
3337
_duration: 100,
3438
_spanContext: {
3539
_name: 'operation'
40+
},
41+
setTag (key, value) {
42+
this._addTags({ [key]: value })
3643
}
3744
}
3845

0 commit comments

Comments
 (0)