Commit d5c9596
perf: use DeepCopyUpdate to eliminate Clone+DeepUpdate allocations
Replace the two-step Clone()+DeepUpdate() pattern with single-pass
DeepCopyUpdate() across hot-path processors and pipeline setup. This
creates fresh nested maps during the merge rather than cloning the
entire source tree first, eliminating intermediate map allocations.
Changes:
- add_fields: detect single-key wrapper shape at init, clone only
inner map at runtime. Split @metadata handling to bypass
event.deepUpdate overhead. Skip no-overwrite merge when all
destination keys exist.
- add_cloud_metadata: replace full metadata.Clone() with per-value
deep copy — strings/numbers returned as-is, only nested maps cloned.
- add_host_metadata: lock-free fast path via atomic timestamp +
mapstr.Pointer. Use DeepCopyUpdate for cached data merge.
- add_observer_metadata: Clone()+DeepUpdate → DeepCopyUpdate.
- rename: skip event.Clone() backup for single-field renames with
different top-level keys (Put-first-then-Delete ordering).
- publisher/processing: Clone()+DeepUpdate → DeepCopyUpdate (3 sites).
- heartbeat/eventext: Clone()+DeepUpdate → DeepCopyUpdate.
Depends on elastic/elastic-agent-libs#390 for DeepCopyUpdate/
DeepCopyUpdateNoOverwrite (temporarily pinned to fork).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2d10f57 commit d5c9596
File tree
14 files changed
+1660
-68
lines changed- changelog/fragments
- heartbeat/eventext
- libbeat
- processors
- actions
- addfields
- add_cloud_metadata
- add_host_metadata
- add_observer_metadata
- publisher/processing
14 files changed
+1660
-68
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
459 | 460 | | |
460 | 461 | | |
461 | 462 | | |
| |||
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
521 | | - | |
| 522 | + | |
522 | 523 | | |
523 | 524 | | |
524 | 525 | | |
| |||
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
| 553 | + | |
| 554 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
| |||
427 | 425 | | |
428 | 426 | | |
429 | 427 | | |
430 | | - | |
431 | | - | |
| 428 | + | |
| 429 | + | |
432 | 430 | | |
433 | 431 | | |
434 | 432 | | |
| |||
604 | 602 | | |
605 | 603 | | |
606 | 604 | | |
607 | | - | |
608 | | - | |
| 605 | + | |
| 606 | + | |
609 | 607 | | |
610 | 608 | | |
611 | 609 | | |
| |||
991 | 989 | | |
992 | 990 | | |
993 | 991 | | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
994 | 996 | | |
995 | 997 | | |
996 | 998 | | |
| |||
1466 | 1468 | | |
1467 | 1469 | | |
1468 | 1470 | | |
1469 | | - | |
1470 | | - | |
| 1471 | + | |
| 1472 | + | |
1471 | 1473 | | |
1472 | 1474 | | |
1473 | 1475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
| |||
58 | 76 | | |
59 | 77 | | |
60 | 78 | | |
61 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
62 | 116 | | |
63 | 117 | | |
64 | 118 | | |
65 | 119 | | |
66 | 120 | | |
67 | 121 | | |
68 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
69 | 217 | | |
70 | 218 | | |
71 | 219 | | |
72 | 220 | | |
73 | | - | |
74 | 221 | | |
75 | 222 | | |
76 | 223 | | |
77 | 224 | | |
78 | 225 | | |
79 | | - | |
80 | 226 | | |
81 | 227 | | |
82 | 228 | | |
| |||
0 commit comments