1. 17 4月, 2019 2 次提交
    • S
      WriteBufferManager's dummy entry size to block cache 1MB -> 256KB (#5175) · beb44ec3
      Siying Dong 提交于
      Summary:
      Dummy cache size of 1MB is too large for small block sizes. Our GetDefaultCacheShardBits() use min_shard_size = 512L * 1024L to determine number of shards, so 1MB will excceeds the size of the whole shard and make the cache excceeds the budget.
      Change it to 256KB accordingly.
      There shouldn't be obvious performance impact, since inserting a cache entry every 256KB of memtable inserts is still infrequently enough.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5175
      
      Differential Revision: D14954289
      
      Pulled By: siying
      
      fbshipit-source-id: 2c275255c1ac3992174e06529e44c55538325c94
      beb44ec3
    • Y
      Avoid per-key upper bound check in BlockBasedTableIterator (#5142) · f1239d5f
      yiwu-arbug 提交于
      Summary:
      This is second attempt for #5101. Original commit message:
      `BlockBasedTableIterator` avoid reading next block on `Next()` if it detects the iterator will be out of bound, by checking against index key. The optimization was added in #2239, and by the time it only check the bound per block. It seems later change make it a per-key check, which introduce unnecessary key comparisons.
      
      This patch come with two fixes:
      
      Fix 1: To optimize checking for bounds, we need comparing the bounds with index key as well. However BlockBasedTableIterator doesn't know whether its index iterator is internally using user keys or internal keys. The patch fixes that by extending InternalIterator with a user_key() function that is overridden by In IndexBlockIter.
      
      Fix 2: In #5101 we return `IsOutOfBound()=true` when block index key is out of bound. But the index key can be larger than smallest key of the next file on the level. That file can be within upper bound and should not be filtered out.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5142
      
      Differential Revision: D14907113
      
      Pulled By: siying
      
      fbshipit-source-id: ac95775c5b4e7b700f76ab43e39f45402c98fbfb
      f1239d5f
  2. 16 4月, 2019 2 次提交
    • V
      Consolidating WAL creation which currently has duplicate logic in... · 71a82a0a
      Vijay Nadimpalli 提交于
      Consolidating WAL creation which currently has duplicate logic in db_impl_write.cc and db_impl_open.cc (#5188)
      
      Summary:
      Right now, two separate pieces of code are used to create WAL files in DBImpl::Open function of db_impl_open.cc and DBImpl::SwitchMemtable function of db_impl_write.cc. This code change simply creates 1 function called DBImpl::CreateWAL in db_impl_open.cc which is used to replace existing WAL creation logic in DBImpl::Open and DBImpl::SwitchMemtable.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5188
      
      Differential Revision: D14942832
      
      Pulled By: vjnadimpalli
      
      fbshipit-source-id: d49230e04c36176015c8c1b422575872f92157fb
      71a82a0a
    • Y
      Fix MultiGet ASSERT bug when passing unsorted result (#5195) · 3e63e553
      Yi Zhang 提交于
      Summary:
      Found this when test driving the new MultiGet. If you pass unsorted result with sorted_result = false you'll trigger the ASSERT incorrect even though we'll sort down below.
      
      I've also added simple test cover sorted_result=true/false scenario copied from MultiGetSimple.
      
      anand1976
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5195
      
      Differential Revision: D14935475
      
      Pulled By: yizhang82
      
      fbshipit-source-id: 1d2af5e3a003847d965066a16e3b19da68acf170
      3e63e553
  3. 13 4月, 2019 5 次提交
    • A
      Add bounds check in FilePickerMultiGet::PrepareNextLevel() (#5189) · 29111e92
      anand76 提交于
      Summary:
      Add bounds check when looping through empty levels in FilePickerMultiGet
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5189
      
      Differential Revision: D14925334
      
      Pulled By: anand1976
      
      fbshipit-source-id: 65d53247cf443153e28ce2b8b753fa51c6ae4566
      29111e92
    • Y
      Fix crash with memtable prefix bloom and key out of prefix extractor domain (#5190) · cca141ec
      yiwu-arbug 提交于
      Summary:
      Before using prefix extractor `InDomain()` should be check. All uses in memtable.cc didn't check `InDomain()`.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5190
      
      Differential Revision: D14923773
      
      Pulled By: miasantreble
      
      fbshipit-source-id: b3ad60bcca5f3a1a2b929a6eb34b0b7ba6326f04
      cca141ec
    • M
      WritePrepared: fix race condition in reading batch with duplicate keys (#5147) · fe642cbe
      Maysam Yabandeh 提交于
      Summary:
      When ReadOption doesn't specify a snapshot, WritePrepared::Get used kMaxSequenceNumber to avoid the cost of creating a new snapshot object (that requires sync over db_mutex). This creates a race condition if it is reading from the writes of a transaction that had duplicate keys: each instance of duplicate key is inserted with a different sequence number and depending on the ordering the ::Get might skip the newer one and read the older one that is obsolete.
      The patch fixes that by using last published seq as the snapshot sequence number. It also adds a check after the read is done to ensure that the max_evicted_seq has not advanced the aforementioned seq, which is a very unlikely event. If it did, then the read is not valid since the seq is not backed by an actually snapshot to let IsInSnapshot handle that properly when an overlapping commit is evicted from commit cache.
      A unit  test is added to reproduce the race condition with duplicate keys.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5147
      
      Differential Revision: D14758815
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: a56915657132cf6ba5e3f5ea1b5d78c803407719
      fe642cbe
    • S
      Still implement StatisticsImpl::measureTime() (#5181) · 85b2bde3
      Siying Dong 提交于
      Summary:
      Since Statistics::measureTime() is deprecated, StatisticsImpl::measureTime() is not implemented. We realized that users might have a wrapped Statistics implementation in which measureTime() is implemented as forwarded to StatisticsImpl, and causes assert failure. In order to make the change less intrusive, we implement StatisticsImpl::measureTime(). We will revisit whether we need to remove it after several releases.
      
      Also, add a test to make sure that a Statistics implementation using the old interface still works.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5181
      
      Differential Revision: D14907089
      
      Pulled By: siying
      
      fbshipit-source-id: 29b6202fd04e30ed6f6adcaeb1000e87f10d1e1a
      85b2bde3
    • Y
      Fix bugs detected by clang analyzer (#5185) · 3189398c
      Yanqin Jin 提交于
      Summary:
      as titled. False positive included, fixed anyway to make the check
      pass.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5185
      
      Differential Revision: D14909384
      
      Pulled By: riversand963
      
      fbshipit-source-id: dc5177e72b1929ccfd6175a60e2cd7bdb9bd80f3
      3189398c
  4. 12 4月, 2019 3 次提交
    • V
      Added missing table properties in log (#5168) · f49e12b8
      vijaynadimpalli 提交于
      Summary:
      When a new SST file is created via flush or compaction, we dump out the table properties, however only a few table properties are logged. The change here is to log all the table properties
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5168
      
      Differential Revision: D14876928
      
      Pulled By: vjnadimpalli
      
      fbshipit-source-id: 1aca42ad00f9f650761d39e187f8beeb8700149b
      f49e12b8
    • A
      Introduce a new MultiGet batching implementation (#5011) · fefd4b98
      anand76 提交于
      Summary:
      This PR introduces a new MultiGet() API, with the underlying implementation grouping keys based on SST file and batching lookups in a file. The reason for the new API is twofold - the definition allows callers to allocate storage for status and values on stack instead of std::vector, as well as return values as PinnableSlices in order to avoid copying, and it keeps the original MultiGet() implementation intact while we experiment with batching.
      
      Batching is useful when there is some spatial locality to the keys being queries, as well as larger batch sizes. The main benefits are due to -
      1. Fewer function calls, especially to BlockBasedTableReader::MultiGet() and FullFilterBlockReader::KeysMayMatch()
      2. Bloom filter cachelines can be prefetched, hiding the cache miss latency
      
      The next step is to optimize the binary searches in the level_storage_info, index blocks and data blocks, since we could reduce the number of key comparisons if the keys are relatively close to each other. The batching optimizations also need to be extended to other formats, such as PlainTable and filter formats. This also needs to be added to db_stress.
      
      Benchmark results from db_bench for various batch size/locality of reference combinations are given below. Locality was simulated by offsetting the keys in a batch by a stride length. Each SST file is about 8.6MB uncompressed and key/value size is 16/100 uncompressed. To focus on the cpu benefit of batching, the runs were single threaded and bound to the same cpu to eliminate interference from other system events. The results show a 10-25% improvement in micros/op from smaller to larger batch sizes (4 - 32).
      
      Batch   Sizes
      
      1        | 2        | 4         | 8      | 16  | 32
      
      Random pattern (Stride length 0)
      4.158 | 4.109 | 4.026 | 4.05 | 4.1 | 4.074        - Get
      4.438 | 4.302 | 4.165 | 4.122 | 4.096 | 4.075 - MultiGet (no batching)
      4.461 | 4.256 | 4.277 | 4.11 | 4.182 | 4.14        - MultiGet (w/ batching)
      
      Good locality (Stride length 16)
      4.048 | 3.659 | 3.248 | 2.99 | 2.84 | 2.753
      4.429 | 3.728 | 3.406 | 3.053 | 2.911 | 2.781
      4.452 | 3.45 | 2.833 | 2.451 | 2.233 | 2.135
      
      Good locality (Stride length 256)
      4.066 | 3.786 | 3.581 | 3.447 | 3.415 | 3.232
      4.406 | 4.005 | 3.644 | 3.49 | 3.381 | 3.268
      4.393 | 3.649 | 3.186 | 2.882 | 2.676 | 2.62
      
      Medium locality (Stride length 4096)
      4.012 | 3.922 | 3.768 | 3.61 | 3.582 | 3.555
      4.364 | 4.057 | 3.791 | 3.65 | 3.57 | 3.465
      4.479 | 3.758 | 3.316 | 3.077 | 2.959 | 2.891
      
      dbbench command used (on a DB with 4 levels, 12 million keys)-
      TEST_TMPDIR=/dev/shm numactl -C 10  ./db_bench.tmp -use_existing_db=true -benchmarks="readseq,multireadrandom" -write_buffer_size=4194304 -target_file_size_base=4194304 -max_bytes_for_level_base=16777216 -num=12000000 -reads=12000000 -duration=90 -threads=1 -compression_type=none -cache_size=4194304000 -batch_size=32 -disable_auto_compactions=true -bloom_bits=10 -cache_index_and_filter_blocks=true -pin_l0_filter_and_index_blocks_in_cache=true -multiread_batched=true -multiread_stride=4
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5011
      
      Differential Revision: D14348703
      
      Pulled By: anand1976
      
      fbshipit-source-id: 774406dab3776d979c809522a67bedac6c17f84b
      fefd4b98
    • S
      Change OptimizeForPointLookup() and OptimizeForSmallDb() (#5165) · ed9f5e21
      Siying Dong 提交于
      Summary:
      Change the behavior of OptimizeForSmallDb() so that it is less likely to go out of memory.
      Change the behavior of OptimizeForPointLookup() to take advantage of the new memtable whole key filter, and move away from prefix extractor as well as hash-based indexing, as they are prone to misuse.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5165
      
      Differential Revision: D14880709
      
      Pulled By: siying
      
      fbshipit-source-id: 9af30e3c9e151eceea6d6b38701a58f1f9fb692d
      ed9f5e21
  5. 11 4月, 2019 1 次提交
    • S
      Periodic Compactions (#5166) · d3d20dcd
      Sagar Vemuri 提交于
      Summary:
      Introducing Periodic Compactions.
      
      This feature allows all the files in a CF to be periodically compacted. It could help in catching any corruptions that could creep into the DB proactively as every file is constantly getting re-compacted.  And also, of course, it helps to cleanup data older than certain threshold.
      
      - Introduced a new option `periodic_compaction_time` to control how long a file can live without being compacted in a CF.
      - This works across all levels.
      - The files are put in the same level after going through the compaction. (Related files in the same level are picked up as `ExpandInputstoCleanCut` is used).
      - Compaction filters, if any, are invoked as usual.
      - A new table property, `file_creation_time`, is introduced to implement this feature. This property is set to the time at which the SST file was created (and that time is given by the underlying Env/OS).
      
      This feature can be enabled on its own, or in conjunction with `ttl`. It is possible to set a different time threshold for the bottom level when used in conjunction with ttl. Since `ttl` works only on 0 to last but one levels, you could set `ttl` to, say, 1 day, and `periodic_compaction_time` to, say, 7 days. Since `ttl < periodic_compaction_time` all files in last but one levels keep getting picked up based on ttl, and almost never based on periodic_compaction_time. The files in the bottom level get picked up for compaction based on `periodic_compaction_time`.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5166
      
      Differential Revision: D14884441
      
      Pulled By: sagar0
      
      fbshipit-source-id: 408426cbacb409c06386a98632dcf90bfa1bda47
      d3d20dcd
  6. 09 4月, 2019 2 次提交
    • S
      Consolidate hash function used for non-persistent data in a new function (#5155) · 0bb55563
      Siying Dong 提交于
      Summary:
      Create new function NPHash64() and GetSliceNPHash64(), which are currently
      implemented using murmurhash.
      Replace the current direct call of murmurhash() to use the new functions
      if the hash results are not used in on-disk format.
      This will make it easier to try out or switch to alternative functions
      in the uses where data format compatibility doesn't need to be considered.
      This part shouldn't have any performance impact.
      
      Also, the sharded cache hash function is changed to the new format, because
      it falls into this categoery. It doesn't show visible performance impact
      in db_bench results. CPU showed by perf is increased from about 0.2% to 0.4%
      in an extreme benchmark setting (4KB blocks, no-compression, everything
      cached in block cache). We've known that the current hash function used,
      our own Hash() has serious hash quality problem. It can generate a lots of
      conflicts with similar input. In this use case, it means extra lock contention
      for reads from the same file. This slight CPU regression is worthy to me
      to counter the potential bad performance with hot keys. And hopefully this
      will get further improved in the future with a better hash function.
      
      cache_test's condition is relaxed a little bit to. The new hash is slightly
      more skewed in this use case, but I manually checked the data and see
      the hash results are still in a reasonable range.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5155
      
      Differential Revision: D14834821
      
      Pulled By: siying
      
      fbshipit-source-id: ec9a2c0a2f8ae4b54d08b13a5c2e9cc97aa80cb5
      0bb55563
    • Y
      Refactor ExternalSSTFileTest (#5129) · de00f281
      Yanqin Jin 提交于
      Summary:
      remove an unnecessary function `GenerateAndAddFileIngestBehind`
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5129
      
      Differential Revision: D14686710
      
      Pulled By: riversand963
      
      fbshipit-source-id: 5698ae63e10f8ef76c2da753bbb07a36024ac065
      de00f281
  7. 06 4月, 2019 1 次提交
    • S
      Expose DB methods to lock and unlock the WAL (#5146) · 39c6c5fc
      Sergei Glushchenko 提交于
      Summary:
      Expose DB methods to lock and unlock the WAL.
      
      These methods are intended to use by MyRocks in order to obtain WAL
      coordinates in consistent way.
      
      Usage scenario is following:
      
      MySQL has performance_schema.log_status which provides information that
      enables a backup tool to copy the required log files without locking for
      the duration of copy. To populate this table MySQL does following:
      
      1. Lock the binary log. Transactions are not allowed to commit now
      2. Save the binary log coordinates
      3. Walk through the storage engines and lock writes on each engine. For
         InnoDB, redo log is locked. For MyRocks, WAL should be locked.
      4. Ask storage engines for their coordinates. InnoDB reports its current
         LSN and checkpoint LSN. MyRocks should report active WAL files names
         and sizes.
      5. Release storage engine's locks
      6. Unlock binary log
      
      Backup tool will then use this information to copy InnoDB, RocksDB and
      MySQL binary logs up to specified positions to end up with consistent DB
      state after restore.
      
      Currently, RocksDB allows to obtain the list of WAL files. Only missing
      bit is the method to lock the writes to WAL files.
      
      LockWAL method must flush the WAL in order for the reported size to be
      accurate (GetSortedWALFiles is using file system stat call to return the
      file size), also, since backup tool is going to copy the WAL, it is
      better to be flushed.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5146
      
      Differential Revision: D14815447
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: eec9535a6025229ed471119f19fe7b3d8ae888a3
      39c6c5fc
  8. 05 4月, 2019 1 次提交
    • A
      Fix many bugs in log statement arguments (#5089) · c06c4c01
      Adam Simpkins 提交于
      Summary:
      Annotate all of the logging functions to inform the compiler that these
      use printf-style formatting arguments.  This allows the compiler to emit
      warnings if the format arguments are incorrect.
      
      This also fixes many problems reported now that format string checking
      is enabled.  Many of these are simply mix-ups in the argument type (e.g,
      int vs uint64_t), but in several cases the wrong number of arguments
      were being passed in which can cause the code to crash.
      
      The primary motivation for this was to fix the log message in
      `DBImpl::SwitchMemtable()` which caused a segfault due to an extra %s
      format parameter with no argument supplied.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5089
      
      Differential Revision: D14574795
      
      Pulled By: simpkins
      
      fbshipit-source-id: 0921b03f0743652bf4ae21e414ff54b3bb65422a
      c06c4c01
  9. 04 4月, 2019 2 次提交
  10. 03 4月, 2019 4 次提交
    • Z
      add assert to silence clang analyzer and fix variable shadowing (#5140) · e8480d4d
      Zhongyi Xie 提交于
      Summary:
      This PR address two open issues:
      
      1.  clang analyzer is paranoid about db_ being nullptr after DB::Open calls in the test.
      See https://github.com/facebook/rocksdb/pull/5043#discussion_r271394579
      Add an assert to keep clang happy
      2. PR https://github.com/facebook/rocksdb/pull/5049 introduced a  variable shadowing:
      ```
      db/db_iterator_test.cc: In constructor ‘rocksdb::DBIteratorWithReadCallbackTest_ReadCallback_Test::TestBody()::TestReadCallback::TestReadCallback(rocksdb::SequenceNumber)’:
      db/db_iterator_test.cc:2484:9: error: declaration of ‘max_visible_seq’ shadows a member of 'this' [-Werror=shadow]
               : ReadCallback(max_visible_seq) {}
               ^
      ```
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5140
      
      Differential Revision: D14735497
      
      Pulled By: miasantreble
      
      fbshipit-source-id: 3219ea75cf4ae04f64d889323f6779e84be98144
      e8480d4d
    • M
      Mark logs with prepare in PreReleaseCallback (#5121) · 5234fc1b
      Maysam Yabandeh 提交于
      Summary:
      In prepare phase of 2PC, the db promises to remember the prepared data, for possible future commits. To fulfill the promise the prepared data must be persisted in the WAL so that they could be recovered after a crash. The log that contains a prepare batch that is not committed yet, is marked so that it is not garbage collected before the transaction commits/rollbacks. The bug was that the write to the log file and the mark of the file was not atomic, and WAL gc could have happened before the WAL log is actually marked. This patch moves the marking logic to PreReleaseCallback so that the WAL gc logic that joins both write threads would see the WAL write and WAL mark atomically.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5121
      
      Differential Revision: D14665210
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 1d66aeb1c66a296cb4899a5a20c4d40c59e4b534
      5234fc1b
    • M
      WriteUnPrepared: less virtual in iterator callback (#5049) · 14b3f683
      Maysam Yabandeh 提交于
      Summary:
      WriteUnPrepared adds a virtual function, MaxUnpreparedSequenceNumber, to ReadCallback, which returns 0 unless WriteUnPrepared is enabled and the transaction has uncommitted data written to the DB. Together with snapshot sequence number, this determines the last sequence that is visible to reads.
      The patch clarifies the guarantees of the GetIterator API in WriteUnPrepared transactions and make use of that to statically initialize the read callback and thus avoid the virtual call.
      Furthermore it increases the minimum value for min_uncommitted from 0 to 1 as seq 0 is used only for last level keys that are committed in all snapshots.
      
      The following benchmark shows +0.26% higher throughput in seekrandom benchmark.
      
      Benchmark:
      ./db_bench --benchmarks=fillrandom --use_existing_db=0 --num=1000000 --db=/dev/shm/dbbench
      
      ./db_bench --benchmarks=seekrandom[X10] --use_existing_db=1 --db=/dev/shm/dbbench --num=1000000 --duration=60 --seek_nexts=100
      seekrandom [AVG    10 runs] : 20355 ops/sec;  225.2 MB/sec
      seekrandom [MEDIAN 10 runs] : 20425 ops/sec;  225.9 MB/sec
      
      ./db_bench_lessvirtual3 --benchmarks=seekrandom[X10] --use_existing_db=1 --db=/dev/shm/dbbench --num=1000000 --duration=60 --seek_nexts=100
      seekrandom [AVG    10 runs] : 20409 ops/sec;  225.8 MB/sec
      seekrandom [MEDIAN 10 runs] : 20487 ops/sec;  226.6 MB/sec
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5049
      
      Differential Revision: D14366459
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: ebaff8908332a5ae9af7defeadabcb624be660ef
      14b3f683
    • S
      Revert "Avoid per-key upper bound check in BlockBasedTableIterator (#5101)" (#5132) · ebcc8ae1
      Siying Dong 提交于
      Summary:
      This reverts commit f29dc1b9.
      
      In BlockBasedTableIterator, index_iter_->key() is sometimes a user key, so it is wrong to call ExtractUserKey() against it. This is a bug introduced by #5101.
      Temporarily revert the diff to keep the branch clean.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5132
      
      Differential Revision: D14718584
      
      Pulled By: siying
      
      fbshipit-source-id: 0ac55dc9b5dbc18c7809092146bdf7eb9364b9ad
      ebcc8ae1
  11. 02 4月, 2019 1 次提交
    • M
      Add DBOptions. avoid_unnecessary_blocking_io to defer file deletions (#5043) · 120bc471
      Mike Kolupaev 提交于
      Summary:
      Just like ReadOptions::background_purge_on_iterator_cleanup but for ColumnFamilyHandle instead of Iterator.
      
      In our use case we sometimes call ColumnFamilyHandle's destructor from low-latency threads, and sometimes it blocks the thread for a few seconds deleting the files. To avoid that, we can either offload ColumnFamilyHandle's destruction to a background thread on our side, or add this option on rocksdb side. This PR does the latter, to be consistent with how we solve exactly the same problem for iterators using background_purge_on_iterator_cleanup option.
      
      (EDIT: It's avoid_unnecessary_blocking_io now, and affects both CF drops and iterator destructors.)
      I'm not quite comfortable with having two separate options (background_purge_on_iterator_cleanup and background_purge_on_cf_cleanup) for such a rarely used thing. Maybe we should merge them? Rename background_purge_on_cf_cleanup to something like delete_files_on_background_threads_only or avoid_blocking_io_in_unexpected_places, and make iterators use it instead of the one in ReadOptions? I can do that here if you guys think it's better.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5043
      
      Differential Revision: D14339233
      
      Pulled By: al13n321
      
      fbshipit-source-id: ccf7efa11c85c9a5b91d969bb55627d0fb01e7b8
      120bc471
  12. 30 3月, 2019 2 次提交
    • Y
      Avoid per-key upper bound check in BlockBasedTableIterator (#5101) · f29dc1b9
      Yi Wu 提交于
      Summary:
      `BlockBasedTableIterator` avoid reading next block on `Next()` if it detects the iterator will be out of bound, by checking against index key. The optimization was added in #2239, and by the time it only check the bound per block. It seems later change make it a per-key check, which introduce unnecessary key comparisons.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5101
      
      Differential Revision: D14678707
      
      Pulled By: siying
      
      fbshipit-source-id: 2372446116753c7892ea4cec7b4b49ef87ba463e
      f29dc1b9
    • Y
      Update RepeatableThreadTest with MockTimeEnv (#5107) · 09957ded
      Yanqin Jin 提交于
      Summary:
      **This PR updates RepeatableThread::wait, breaking some tests on OS X. The rest of the PR fixes the tests on OS X.**
      `RepeatableThreadTest.MockEnvTest` uses `MockTimeEnv` and `RepeatableThread`. If `RepeatableThread::wait` calls `TimedWait` with a time smaller than or equal to the current (real) time, `TimedWait` returns immediately on certain platforms, e.g. OS X. #4560 addresses this issue by replacing `TimedWait` with `Wait` in test. This fixes the test but makes test/production code diverge, which is not optimal for test coverage. This PR proposes an alternative fix which unifies test and production code path for `RepeatableThread::wait`. We obtain the current (real) time in seconds and add 10 extra seconds to ensure that `RepeatableThread::wait` invokes `TimedWait` with a time greater than (real) current time. This is to prevent the `TimedWait` function from returning immediately without sleeping and releasing the mutex. If `TimedWait` returns immediately, the mutex will not be released, and `RepeatableThread::TEST_WaitForRun` never has a chance to execute the callback which, in this case, updates the result returned by `mock_env->NowMicros()`. Consequently, `RepeatableThread::wait` cannot break out of the loop, causing test to hang. The extra 10 seconds is a best-effort approach because there seems no reliable and deterministic way to provide the aforementioned guarantee. By the time `RepeatableThread::wait` is called, there is no guarantee that the `delay + mock_env->NowMicros()` will be greater than the current real time. However, 10 seconds should be sufficient in most cases. We will keep an eye for possible flakiness of this test.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5107
      
      Differential Revision: D14680885
      
      Pulled By: riversand963
      
      fbshipit-source-id: d1ecbe10e1dacd110bd464cd01e188bfee72b89e
      09957ded
  13. 29 3月, 2019 2 次提交
    • A
      Smooth the deletion of WAL files (#5116) · dae3b554
      anand76 提交于
      Summary:
      WAL files are currently not subject to deletion rate limiting by DeleteScheduler. If the size of the WAL files is significant, this can cause a high delete rate on SSDs that may affect other operations. To fix it, force WAL file deletions to go through the SstFileManager. Original PR for this is #2768
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5116
      
      Differential Revision: D14669437
      
      Pulled By: anand1976
      
      fbshipit-source-id: c5f62d0640cebaa1574de841a1d01e4ce2faadf0
      dae3b554
    • S
      Improve obsolete_files_test (#5125) · 106a94af
      Siying Dong 提交于
      Summary:
      We see a failure of obsolete_files_test but aren't able to identify
      the issue. Improve the test in following way and hope we can debug
      better next time:
      1. Place sync point before automatic compaction runs so race condition
         will always trigger.
      2. Disable sync point before test finishes.
      3. ASSERT_OK() instead of ASSERT_TRUE(status.ok())
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5125
      
      Differential Revision: D14669456
      
      Pulled By: siying
      
      fbshipit-source-id: dccb7648e334501ad651eb212880096eef1f4ab2
      106a94af
  14. 28 3月, 2019 4 次提交
  15. 27 3月, 2019 2 次提交
    • Y
      Support for single-primary, multi-secondary instances (#4899) · 9358178e
      Yanqin Jin 提交于
      Summary:
      This PR allows RocksDB to run in single-primary, multi-secondary process mode.
      The writer is a regular RocksDB (e.g. an `DBImpl`) instance playing the role of a primary.
      Multiple `DBImplSecondary` processes (secondaries) share the same set of SST files, MANIFEST, WAL files with the primary. Secondaries tail the MANIFEST of the primary and apply updates to their own in-memory state of the file system, e.g. `VersionStorageInfo`.
      
      This PR has several components:
      1. (Originally in #4745). Add a `PathNotFound` subcode to `IOError` to denote the failure when a secondary tries to open a file which has been deleted by the primary.
      
      2. (Similar to #4602). Add `FragmentBufferedReader` to handle partially-read, trailing record at the end of a log from where future read can continue.
      
      3. (Originally in #4710 and #4820). Add implementation of the secondary, i.e. `DBImplSecondary`.
      3.1 Tail the primary's MANIFEST during recovery.
      3.2 Tail the primary's MANIFEST during normal processing by calling `ReadAndApply`.
      3.3 Tailing WAL will be in a future PR.
      
      4. Add an example in 'examples/multi_processes_example.cc' to demonstrate the usage of secondary RocksDB instance in a multi-process setting. Instructions to run the example can be found at the beginning of the source code.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/4899
      
      Differential Revision: D14510945
      
      Pulled By: riversand963
      
      fbshipit-source-id: 4ac1c5693e6012ad23f7b4b42d3c374fecbe8886
      9358178e
    • S
      Introduce CPU timers for iterator seek and next (#5076) · 01e6badb
      Shi Feng 提交于
      Summary:
      Introduce CPU timers for iterator seek and next operations. Seek
      counter includes SeekToFirst, SeekToLast and SeekForPrev, w/ the
      caveat that SeekToLast timer doesn't include some post processing
      time if upper bound is defined.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5076
      
      Differential Revision: D14525218
      
      Pulled By: fredfsh
      
      fbshipit-source-id: 03ba25df3b22b06c072621e4de0eacfa1445f0d9
      01e6badb
  16. 26 3月, 2019 1 次提交
  17. 22 3月, 2019 1 次提交
    • M
      Reorder DBIter fields to reduce memory usage (#5078) · c84fad7a
      Maysam Yabandeh 提交于
      Summary:
      The patch reorders DBIter fields to put 1-byte fields together and let the compiler optimize the memory usage by using less 64-bit allocations for bools and enums.
      
      This might have a negative side effect of putting the variables that are accessed together into different cache lines and hence increasing the cache misses. Not sure what benchmark would verify that thought. I ran simple, single-threaded seekrandom benchmarks but the variance in the results is too much to be conclusive.
      
      ./db_bench --benchmarks=fillrandom --use_existing_db=0 --num=1000000 --db=/dev/shm/dbbench
      ./db_bench --benchmarks=seekrandom[X10] --use_existing_db=1 --db=/dev/shm/dbbench --num=1000000 --duration=60 --seek_nexts=100
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5078
      
      Differential Revision: D14562676
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 2284655d46e079b6e9a860e94be5defb6f482167
      c84fad7a
  18. 20 3月, 2019 3 次提交
    • Z
      Collect compaction stats by priority and dump to info LOG (#5050) · a291f3a1
      Zhongyi Xie 提交于
      Summary:
      In order to better understand compaction done by different priority thread pool, we now collect compaction stats by priority and also print them to info LOG through stats dump.
      
      ```
      ** Compaction Stats [default] **
      Priority    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
      -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       Low      0/0    0.00 KB   0.0     16.8    11.3      5.5       5.6      0.1       0.0   0.0    406.4    136.1     42.24             34.96        45    0.939     13M  8865K
      High      0/0    0.00 KB   0.0      0.0     0.0      0.0      11.4     11.4       0.0   0.0      0.0     76.2    153.00             35.74     12185    0.013       0      0
      ```
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5050
      
      Differential Revision: D14408583
      
      Pulled By: miasantreble
      
      fbshipit-source-id: e53746586ea27cb8abc9fec35805bd80ed30f608
      a291f3a1
    • W
      Add an option to filter traces (#5082) · 36c2a7cf
      Wenjie Yang 提交于
      Summary:
      Add an option to filter out READ or WRITE operations while tracing.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5082
      
      Differential Revision: D14515083
      
      Pulled By: mrmiywj
      
      fbshipit-source-id: 2504c89a9abf1dd629cad44b4104092702d77610
      36c2a7cf
    • H
      Add missing C API for transaction (#5077) · f2f6acbe
      Hiroaki Nakamura 提交于
      Summary:
      Partly addresses https://github.com/facebook/rocksdb/issues/4999
      I verified `make static_lib` runs fine.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/5077
      
      Differential Revision: D14521101
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: ba88e74a51d2d793cac7260d505b1a54254b53af
      f2f6acbe
  19. 19 3月, 2019 1 次提交
    • S
      Feature for sampling and reporting compressibility (#4842) · b45b1cde
      Shobhit Dayal 提交于
      Summary:
      This is a feature to sample data-block compressibility and and report them as stats. 1 in N (tunable) blocks is sampled for compressibility using two algorithms:
      1. lz4 or snappy for fast compression
      2. zstd or zlib for slow but higher compression.
      
      The stats are reported to the caller as raw-bytes and compressed-bytes. The block continues to be compressed for storage using the specified CompressionType.
      
      The db_bench_tool how has a command line option for specifying the sampling rate. It's default value is 0 (no sampling). To test the overhead for a certain value, users can compare the performance of db_bench_tool, varying the sampling rate. It is unlikely to have a noticeable impact for high values like 20.
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/4842
      
      Differential Revision: D13629011
      
      Pulled By: shobhitdayal
      
      fbshipit-source-id: 14ca668bcab6499b2a1734edf848eb62a4f4fafa
      b45b1cde