Commit ca22b1d
authored
Use pointer when passing TransformContext around or calling into (open-telemetry#44541)
This PR changes only the `ottlspan.TransformContext`, if gets approved
will file separate PRs for all contexts.
* In OTTL Expr and Getter/Setter the TransformContext is no longer pass
as value avoiding a copy of 12 words (96B) every time an
Expr/Getter/Setter of even simple Get* on the context itself funcs are
called.
* Avoid allocating a new pcommon.Map every time, very costly when is not
needed.
Comparing existing benchmarks:
**Before:**
```
BenchmarkTwoSpans
BenchmarkTwoSpans/no_processing
BenchmarkTwoSpans/no_processing-12 841123 1327 ns/op 2592 B/op 46 allocs/op
BenchmarkTwoSpans/set_attribute
BenchmarkTwoSpans/set_attribute-12 743674 1600 ns/op 2640 B/op 49 allocs/op
BenchmarkTwoSpans/keep_keys_attribute
BenchmarkTwoSpans/keep_keys_attribute-12 715513 1685 ns/op 2656 B/op 50 allocs/op
BenchmarkTwoSpans/no_match
BenchmarkTwoSpans/no_match-12 702061 1554 ns/op 2624 B/op 48 allocs/op
BenchmarkTwoSpans/inner_field
BenchmarkTwoSpans/inner_field-12 721738 1621 ns/op 2624 B/op 48 allocs/op
BenchmarkTwoSpans/inner_field_both_spans
BenchmarkTwoSpans/inner_field_both_spans-12 716055 1713 ns/op 2656 B/op 50 allocs/op
```
**After:**
```
BenchmarkTwoSpans
BenchmarkTwoSpans/no_processing
BenchmarkTwoSpans/no_processing-12 1000000 1244 ns/op 2337 B/op 40 allocs/op
BenchmarkTwoSpans/set_attribute
BenchmarkTwoSpans/set_attribute-12 885855 1369 ns/op 2385 B/op 43 allocs/op
BenchmarkTwoSpans/keep_keys_attribute
BenchmarkTwoSpans/keep_keys_attribute-12 812374 1448 ns/op 2401 B/op 44 allocs/op
BenchmarkTwoSpans/no_match
BenchmarkTwoSpans/no_match-12 886906 1331 ns/op 2369 B/op 42 allocs/op
BenchmarkTwoSpans/inner_field
BenchmarkTwoSpans/inner_field-12 871096 1374 ns/op 2369 B/op 42 allocs/op
BenchmarkTwoSpans/inner_field_both_spans
BenchmarkTwoSpans/inner_field_both_spans-12 866323 1417 ns/op 2401 B/op 44 allocs/op
```
Comparing benchmarks that do not need to allocate the data again every
iteration and does not change the data to measure only the OTTL
overhead:
**Before:**
```
BenchmarkSetName
BenchmarkSetName-12 9204532 122.0 ns/op 32 B/op 2 allocs/op
```
**After:**
```
BenchmarkSetName
BenchmarkSetName-12 3745602 305.7 ns/op 288 B/op 8 allocs/op
```
For the current performance benchmarks which are not allocating new
TransformContext, here only benefit is because of the object copy part:
**Before:**
```
BenchmarkStatementSequenceExecuteSpans
BenchmarkStatementSequenceExecuteSpans/small
BenchmarkStatementSequenceExecuteSpans/small-12 1000000 1004 ns/op 264 B/op 16 allocs/op
BenchmarkStatementSequenceExecuteSpans/medium
BenchmarkStatementSequenceExecuteSpans/medium-12 189889 6194 ns/op 1464 B/op 86 allocs/op
BenchmarkStatementSequenceExecuteSpans/large
BenchmarkStatementSequenceExecuteSpans/large-12 29114 39433 ns/op 6000 B/op 350 allocs/op
```
**After:**
```
BenchmarkStatementSequenceExecuteSpans
BenchmarkStatementSequenceExecuteSpans/small
BenchmarkStatementSequenceExecuteSpans/small-12 1915495 603.9 ns/op 264 B/op 16 allocs/op
BenchmarkStatementSequenceExecuteSpans/medium
BenchmarkStatementSequenceExecuteSpans/medium-12 279411 4292 ns/op 1464 B/op 86 allocs/op
BenchmarkStatementSequenceExecuteSpans/large
BenchmarkStatementSequenceExecuteSpans/large-12 34627 34848 ns/op 6000 B/op 350 allocs/op
```
Signed-off-by: Bogdan Drutu <[email protected]>1 parent 9cbe6fb commit ca22b1d
File tree
48 files changed
+488
-270
lines changed- .chloggen
- connector
- countconnector
- routingconnector
- signaltometricsconnector
- internal
- customottl
- model
- sumconnector
- internal/filter
- filterottl
- filterspan
- pkg/ottl
- contexts/ottlspan
- e2e
- ottlfuncs
- processor
- attributesprocessor
- filterprocessor
- spanprocessor
- tailsamplingprocessor/internal/sampling
- transformprocessor
- internal
- common
- traces
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
48 files changed
+488
-270
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
| 218 | + | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
83 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
0 commit comments