]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/StackStringStream: don't reserve before every insert
authorIlya Dryomov <idryomov@gmail.com>
Mon, 22 Oct 2018 15:39:11 +0000 (17:39 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 22 Oct 2018 18:09:10 +0000 (20:09 +0200)
commit5f25c0ab306503f2daddac33af1dbca554427c29
tree57eca36b1325d883d7e0d75928cfc7c6f61b099d
parent4af71e7c002effa01a1c2d14cad41e270101a7b3
common/StackStringStream: don't reserve before every insert

Unlike ConcreteEntry, MutableEntry can be appended to.  Reserving the
exact number of elements before every append is harmful: vector will
likely reallocate each time and grow linearly instead of geometrically.
This results in quadratic behaviour when we spill past the preallocated
capacity and doesn't benefit the fast path in any way.

The new test case takes half a second with this patch and many hours
spinning in memmove without this patch.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/common/StackStringStream.h
src/log/test.cc