rocksdb/table
Jay Edgar efd013d6d8 Miscellaneous performance improvements
Summary:
I was investigating performance issues in the SstFileWriter and found all of the following:

- The SstFileWriter::Add() function created a local InternalKey every time it was called generating a allocation and free each time.  Changed to have an InternalKey member variable that can be reset with the new InternalKey::Set() function.
- In SstFileWriter::Add() the smallest_key and largest_key values were assigned the result of a ToString() call, but it is simpler to just assign them directly from the user's key.
- The Slice class had no move constructor so each time one was returned from a function a new one had to be allocated, the old data copied to the new, and the old one was freed.  I added the move constructor which also required a copy constructor and assignment operator.
- The BlockBuilder::CurrentSizeEstimate() function calculates the current estimate size, but was being called 2 or 3 times for each key added.  I changed the class to maintain a running estimate (equal to the original calculation) so that the function can return an already calculated value.
- The code in BlockBuilder::Add() that calculated the shared bytes between the last key and the new key duplicated what Slice::difference_offset does, so I replaced it with the standard function.
- BlockBuilder::Add() had code to copy just the changed portion into the last key value (and asserted that it now matched the new key).  It is more efficient just to copy the whole new key over.
- Moved this same code up into the 'if (use_delta_encoding_)' since the last key value is only needed when delta encoding is on.
- FlushBlockBySizePolicy::BlockAlmostFull calculated a standard deviation value each time it was called, but this information would only change if block_size of block_size_deviation changed, so I created a member variable to hold the value to avoid the calculation each time.
- Each PutVarint??() function has a buffer and calls std::string::append().  Two or three calls in a row could share a buffer and a single call to std::string::append().

Some of these will be helpful outside of the SstFileWriter.  I'm not 100% the addition of the move constructor is appropriate as I wonder why this wasn't done before - maybe because of compiler compatibility?  I tried it on gcc 4.8 and 4.9.

Test Plan: The changes should not affect the results so the existing tests should all still work and no new tests were added.  The value of the changes was seen by manually testing the SstFileWriter class through MyRocks and adding timing code to identify problem areas.

Reviewers: sdong, IslamAbdelRahman

Reviewed By: IslamAbdelRahman

Subscribers: andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D59607
2016-07-12 14:15:32 -07:00
..
adaptive_table_factory.cc Fix null-pointer-dereference detected by Infer (https://github.com/facebook/infer) 2016-04-25 20:09:36 +01:00
adaptive_table_factory.h Pass column family ID to table property collector 2015-10-09 14:36:51 -07:00
block_based_filter_block_test.cc Add statistics field to show total size of index and filter blocks in block cache 2016-06-03 10:47:47 -07:00
block_based_filter_block.cc BlockBasedTable::FullFilterKeyMayMatch() Should skip prefix bloom if full key bloom exists 2016-06-10 16:27:56 -07:00
block_based_filter_block.h BlockBasedTable::FullFilterKeyMayMatch() Should skip prefix bloom if full key bloom exists 2016-06-10 16:27:56 -07:00
block_based_table_builder.cc Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
block_based_table_builder.h Shared dictionary compression using reference block 2016-04-27 17:36:03 -07:00
block_based_table_factory.cc Shared dictionary compression using reference block 2016-04-27 17:36:03 -07:00
block_based_table_factory.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
block_based_table_reader.cc Fix clang analyzer errors 2016-07-08 17:50:51 -07:00
block_based_table_reader.h Add statistics field to show total size of index and filter blocks in block cache 2016-06-03 10:47:47 -07:00
block_builder.cc Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
block_builder.h Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
block_prefix_index.cc Fix clang analyzer errors 2016-07-08 17:50:51 -07:00
block_prefix_index.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
block_test.cc Deprecate BlockBasedTableOptions.hash_index_allow_collision=false. 2016-05-20 17:52:27 -07:00
block.cc Fix clang analyzer errors 2016-07-08 17:50:51 -07:00
block.h Optimize BlockIter::Prev() by caching decoded entries 2016-06-14 12:27:46 -07:00
bloom_block.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
bloom_block.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
cuckoo_table_builder_test.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
cuckoo_table_builder.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
cuckoo_table_builder.h Embed column family name in SST file 2016-04-06 23:10:32 -07:00
cuckoo_table_factory.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
cuckoo_table_factory.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
cuckoo_table_reader_test.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
cuckoo_table_reader.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
cuckoo_table_reader.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
filter_block.h BlockBasedTable::FullFilterKeyMayMatch() Should skip prefix bloom if full key bloom exists 2016-06-10 16:27:56 -07:00
flush_block_policy.cc Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
format.cc Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
format.h Add a check mode to verify compressed block can be decompressed back 2016-06-10 18:20:54 -07:00
full_filter_block_test.cc Add statistics field to show total size of index and filter blocks in block cache 2016-06-03 10:47:47 -07:00
full_filter_block.cc BlockBasedTable::FullFilterKeyMayMatch() Should skip prefix bloom if full key bloom exists 2016-06-10 16:27:56 -07:00
full_filter_block.h BlockBasedTable::FullFilterKeyMayMatch() Should skip prefix bloom if full key bloom exists 2016-06-10 16:27:56 -07:00
get_context.cc Reuse TimedFullMerge instead of FullMerge + instrumentation 2016-06-13 16:17:26 -07:00
get_context.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
internal_iterator.h Introduce PinnedIteratorsManager (Reduce PinData() overhead / Refactor PinData) 2016-04-26 12:41:07 -07:00
iter_heap.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
iterator_wrapper.h Introduce PinnedIteratorsManager (Reduce PinData() overhead / Refactor PinData) 2016-04-26 12:41:07 -07:00
iterator.cc Rename iterator property "rocksdb.iterator.is.key.pinned" => "rocksdb.iterator.is-key-pinned" 2016-03-01 13:47:12 -08:00
merger_test.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
merger.cc Introduce PinnedIteratorsManager (Reduce PinData() overhead / Refactor PinData) 2016-04-26 12:41:07 -07:00
merger.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
meta_blocks.cc Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
meta_blocks.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
mock_table.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
mock_table.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
persistent_cache_helper.cc Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
persistent_cache_helper.h Added PersistentCache abstraction 2016-05-15 22:17:18 -07:00
plain_table_builder.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
plain_table_builder.h Embed column family name in SST file 2016-04-06 23:10:32 -07:00
plain_table_factory.cc Embed column family name in SST file 2016-04-06 23:10:32 -07:00
plain_table_factory.h Fix build broken by previous commit of "option helper refactor" 2015-11-17 16:52:54 -08:00
plain_table_index.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
plain_table_index.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
plain_table_key_coding.cc Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
plain_table_key_coding.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
plain_table_reader.cc Skip bottom-level filter block caching when hit-optimized 2015-12-23 10:15:07 -08:00
plain_table_reader.h Skip bottom-level filter block caching when hit-optimized 2015-12-23 10:15:07 -08:00
scoped_arena_iterator.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00
sst_file_writer.cc Miscellaneous performance improvements 2016-07-12 14:15:32 -07:00
table_builder.h Shared dictionary compression using reference block 2016-04-27 17:36:03 -07:00
table_properties_internal.h Shared dictionary compression using reference block 2016-04-27 17:36:03 -07:00
table_properties.cc Store SST file compression algorithm as a TableProperty 2016-05-12 09:47:16 -07:00
table_reader_bench.cc Shared dictionary compression using reference block 2016-04-27 17:36:03 -07:00
table_reader.h Adding pin_l0_filter_and_index_blocks_in_cache feature and related fixes. 2016-04-01 10:42:39 -07:00
table_test.cc Fix clang analyzer errors 2016-07-08 17:50:51 -07:00
two_level_iterator.cc Introduce PinnedIteratorsManager (Reduce PinData() overhead / Refactor PinData) 2016-04-26 12:41:07 -07:00
two_level_iterator.h Updated all copyright headers to the new format. 2016-02-09 15:12:00 -08:00