rocksdb/table
Jay Zhuang 0d885e80d4 Avoid dynamic memory allocation on read path (#10453)
Summary:
lambda function dynamicly allocates memory from heap if it needs to
capture multiple values, which could be expensive.
Switch to explictly use local functor from stack.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10453

Test Plan:
CI
db_bench shows ~2-3% read improvement:
```
# before the change
TEST_TMPDIR=/tmp/dbbench4 ./db_bench_main --benchmarks=filluniquerandom,readrandom -compression_type=none -max_background_jobs=12 -num=10000000
readrandom   :       8.528 micros/op 117265 ops/sec 85.277 seconds 10000000 operations;   13.0 MB/s (10000000 of 10000000 found)
# after the change
TEST_TMPDIR=/tmp/dbbench5 ./db_bench_new --benchmarks=filluniquerandom,readrandom -compression_type=none -max_background_jobs=12 -num=10000000
readrandom   :       8.263 micros/op 121015 ops/sec 82.634 seconds 10000000 operations;   13.4 MB/s (10000000 of 10000000 found)
```
details: https://gist.github.com/jay-zhuang/5ac0628db8fc9cbcb499e056d4cb5918

Micro-benchmark shows a similar improvement ~1-2%:
before the change:
https://gist.github.com/jay-zhuang/9dc0ebf51bbfbf4af82f6193d43cf75b
after the change:
https://gist.github.com/jay-zhuang/fc061f1813cd8f441109ad0b0fe7c185

Reviewed By: ajkr

Differential Revision: D38345056

Pulled By: jay-zhuang

fbshipit-source-id: f3597aeeee338a804d37bf2e81386d5a100665e0
2022-08-08 12:59:31 -07:00
..
adaptive
block_based Avoid dynamic memory allocation on read path (#10453) 2022-08-08 12:59:31 -07:00
cuckoo
plain Add seqno to time mapping (#10338) 2022-07-14 21:49:34 -07:00
block_fetcher.cc
block_fetcher.h
block_fetcher_test.cc
cleanable_test.cc
format.cc
format.h
get_context.cc Have Cache use Status::MemoryLimit (#10262) 2022-07-06 14:41:46 -07:00
get_context.h
internal_iterator.h Make InternalKeyComparator not configurable (#10342) 2022-07-14 10:09:31 -07:00
iter_heap.h
iterator.cc
iterator_wrapper.h
merger_test.cc
merging_iterator.cc
merging_iterator.h
meta_blocks.cc Add seqno to time mapping (#10338) 2022-07-14 21:49:34 -07:00
meta_blocks.h
mock_table.cc
mock_table.h
multiget_context.h
persistent_cache_helper.cc
persistent_cache_helper.h
persistent_cache_options.h
scoped_arena_iterator.h
sst_file_dumper.cc Remove customized naming from InternalKeyComparator (#10343) 2022-07-12 13:30:35 -07:00
sst_file_dumper.h
sst_file_reader.cc
sst_file_reader_test.cc
sst_file_writer.cc Add seqno to time mapping (#10338) 2022-07-14 21:49:34 -07:00
sst_file_writer_collectors.h
table_builder.h Add seqno to time mapping (#10338) 2022-07-14 21:49:34 -07:00
table_factory.cc
table_properties.cc Add seqno to time mapping (#10338) 2022-07-14 21:49:34 -07:00
table_properties_internal.h
table_reader.h Break TableReader MultiGet into filter and lookup stages (#10432) 2022-08-04 12:51:57 -07:00
table_reader_bench.cc
table_reader_caller.h
table_test.cc Fragment memtable range tombstone in the write path (#10380) 2022-08-05 12:02:33 -07:00
two_level_iterator.cc
two_level_iterator.h
unique_id.cc
unique_id_impl.h