[libcxx-commits] [PATCH] D102727: Use precise growth rather than amortized growth in std::string::resize/__resize_default_init.

Martijn Vels via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 20 14:12:08 PDT 2021


mvels added a comment.

> `_LIBCPP_ABI_UNSTABLE` is meant for improvements (in correctness, performance or other) that require breaking the ABI.

My main point is that this change is a good opportunity for something at Google scale, but of lesser value for most other users. An O(0.2) win on string heap that comes with an O(SQR) sharp edge on hot 'resize()` loops which used to be amortized O(N) is a sharp edge and scary proposition.

I understand your point on the ABI flag being targeted at 'stable ABI' only, yet we have no means at all for other 'tomorrow's invariants and behaviors'. The fact that the standard leaves the amortized growth 'open' is unfortunate, as it's not unreasonable for users to expect amortized growth, and we are basically rolling the "this is fine" dice for everybody else, and we know that there "will" be such pathological use cases in practice. I don't expect the world to burn down, but from a "respect the user" perspective, I'd really like some form / way to have users consciously opt in for a new version.

> whether we want this change

It depends on how we define 'we'.  Mandatory xkcd: https://xkcd.com/1172/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102727/new/

https://reviews.llvm.org/D102727



More information about the libcxx-commits mailing list