[libcxx-commits] [PATCH] D109510: [libc++] string: Allocate exactly when growing from short to long string.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 9 14:42:55 PDT 2021
Quuxplusone added a comment.
> We have measured this overhead to be significant on our (Google) internal workloads, as 64% of global string allocations (and 26% of allocated bytes) are 48 bytes.
And after this patch, what are the numbers? Does it become, for example, "30% of global string allocations are 48 bytes and 34% are 32 bytes"?
Seems plausibly like a good idea to me, but I think your rationale is conspicuously incomplete without those "after" numbers.
================
Comment at: libcxx/include/string:2316
pointer __old_p = __get_pointer();
+ const bool __was_short = __old_cap + 1 == __min_cap;
size_type __cap = __old_cap < __ms / 2 - __alignment ?
----------------
FWIW, I'd rather see `bool __was_short = __old_cap < __min_cap;` — no const (for consistency with every other variable in this function even though, sure, we're not planning to modify any of them), and shorter/simpler condition. Assuming the condition `__old_cap < __min_cap` remains correct, that is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109510/new/
https://reviews.llvm.org/D109510
More information about the libcxx-commits
mailing list