Commit 55044b4
committed
revert(prefix-source): drop buffer() override — CodSpeed regressed -77%
CodSpeed (PR #211) flagged:
prefix-source: buffer() 3.6 ms -> 16 ms (-77.46%)
prefix-source: size() 3.6 ms -> 16 ms (-77.44%)
(size() falls back to this.buffer().length, so it tracks buffer())
Why local wall-clock disagreed with CI: my JS-side splice loop
(allocUnsafe + per-line indexOf + Buffer.copy) does ~1000 JS<->C++
boundary crossings on the es6-promise.js fixture. Modern CPUs
amortize that with branch prediction and cache, so wall-clock looked
+17%. CodSpeed measures instruction count via simulation, which
counts every boundary crossing — and V8's regex.replace +
Buffer.from(string, "utf8") is two big native calls that beat the
loop on that metric by a wide margin.
Caching the result was off the table from the earlier audit
(_source can be mutable). With both single-pass copy AND caching
ruled out, there's no path to a faster buffer() in pure JS, so
the inherited Source.buffer() default stays.
buffers() override stays — it's a new benchmark (no base to regress
against) and matches the changeset description "more effective
buffers for PrefixSource". Consumers that can accept Buffer[]
(writev, fs.createWriteStream) skip the intermediate concatenated
buffer; consumers that want a single buffer use buffer() and pay
the same as before.
The mutable-child regression test still passes.
https://claude.ai/code/session_01EHhGq9PRFRGefVtwwasCqZ1 parent 683c2b7 commit 55044b4
1 file changed
Lines changed: 10 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
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 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
114 | 75 | | |
115 | 76 | | |
116 | 77 | | |
| |||
0 commit comments