Revision 0454f781c262f8134f6d976295a3290f02724197 authored by Andrew Kryczka on 16 February 2018, 03:30:52 UTC, committed by Facebook Github Bot on 16 February 2018, 03:41:52 UTC
Summary:
Calling `std::vector::reserve()` causes memory to be reallocated and then data to be moved. It was called prior to adding every block. This reallocation could be done a huge amount of times, e.g., for users with large index blocks.

Instead, we can simply use `std::vector::emplace_back()` in such a way that preserves the no-memory-leak guarantee, while letting the vector decide when to reallocate space. Now I see reallocation/moving happen O(logN) times, rather than O(N) times, where N is the final size of vector.
Closes https://github.com/facebook/rocksdb/pull/3508

Differential Revision: D6994228

Pulled By: ajkr

fbshipit-source-id: ab7c11e13ff37c8c6c8249be7a79566a4068cd27
1 parent 989d123
History
File Mode Size
env.cc -rw-r--r-- 10.5 KB
env_basic_test.cc -rw-r--r-- 12.6 KB
env_chroot.cc -rw-r--r-- 12.0 KB
env_chroot.h -rw-r--r-- 684 bytes
env_encryption.cc -rw-r--r-- 32.8 KB
env_hdfs.cc -rw-r--r-- 18.4 KB
env_posix.cc -rw-r--r-- 30.4 KB
env_test.cc -rw-r--r-- 46.8 KB
io_posix.cc -rw-r--r-- 28.8 KB
io_posix.h -rw-r--r-- 8.1 KB
mock_env.cc -rw-r--r-- 20.8 KB
mock_env.h -rw-r--r-- 4.2 KB
mock_env_test.cc -rw-r--r-- 2.6 KB
posix_logger.h -rw-r--r-- 5.1 KB

back to top