rocksdb/env
Cheng Chang 2d9efc9ab2 Cache result of GetLogicalBufferSize in Linux (#6457)
Summary:
In Linux, when reopening DB with many SST files, profiling shows that 100% system cpu time spent for a couple of seconds for `GetLogicalBufferSize`. This slows down MyRocks' recovery time when site is down.

This PR introduces two new APIs:
1. `Env::RegisterDbPaths` and `Env::UnregisterDbPaths` lets `DB` tell the env when it starts or stops using its database directories . The `PosixFileSystem` takes this opportunity to set up a cache from database directories to the corresponding logical block sizes.
2. `LogicalBlockSizeCache` is defined only for OS_LINUX to cache the logical block sizes.

Other modifications:
1. rename `logical buffer size` to `logical block size` to be consistent with Linux terms.
2. declare `GetLogicalBlockSize` in `PosixHelper` to expose it to `PosixFileSystem`.
3. change the functions `IOError` and `IOStatus` in `env/io_posix.h` to have external linkage since they are used in other translation units too.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6457

Test Plan:
1. A new unit test is added for `LogicalBlockSizeCache` in `env/io_posix_test.cc`.
2. A new integration test is added for `DB` operations related to the cache in `db/db_logical_block_size_cache_test.cc`.

`make check`

Differential Revision: D20131243

Pulled By: cheng-chang

fbshipit-source-id: 3077c50f8065c0bffb544d8f49fb10bba9408d04
2020-03-11 18:40:05 -07:00
..
composite_env_wrapper.h Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
env_basic_test.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
env_chroot.cc Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
env_chroot.h Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
env_encryption.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
env_hdfs.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
env_posix.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
env_test.cc Add more unit test coverage to MultiRead (#6452) 2020-02-28 16:42:44 -08:00
env.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
file_system.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
fs_posix.cc Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
io_posix_test.cc Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
io_posix.cc Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
io_posix.h Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00
mock_env_test.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
mock_env.cc Add missing MutexLock to MockEnv::CreateDir (#6474) 2020-03-02 20:52:19 -08:00
mock_env.h Cache result of GetLogicalBufferSize in Linux (#6457) 2020-03-11 18:40:05 -07:00