reuse existing capacity in sbo_buffer::grow - #1178
Conversation
|
An automated preview of the documentation is available at https://1178.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-07-30 07:23:56 UTC |
|
GCOVR code coverage report https://1178.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-07-30 07:38:54 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1178 +/- ##
========================================
Coverage 93.92% 93.92%
========================================
Files 91 91
Lines 9279 9285 +6
========================================
+ Hits 8715 8721 +6
Misses 564 564
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
|
|
Thank you for catching this. |

Repro: a 200-element
[1.25,...]array (1001 bytes) fed tostream_parsera byte at a time withnumber_precision::precise, so every number straddles awrite_someboundary, makes 813 globaloperator newcalls totalling 56.1 GB with a largest single block of 1.14 GB; a 32 KB body in 4 KiB chunks peaks at a 2.2 MB block, and that peak keeps doubling as the body grows.Cause:
grownever checks whether the buffer already has room, so everyappendreallocates and each one floors the new capacity atold_capacity * 2, whileclearkeeps the block, so the doubling carries across numbers and acrossreset, and the inline buffer goes unused past the first append.Fix: return early when the requested size fits the current capacity, matching what
string_impl::appendalready does; the two runs above then total 19.8 kB and 240 kB, with largest blocks of 6 kB and 48 kB.