-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flush memtable and compact L0 files for read only workloads #427
Comments
With sysbench read-only range query tests I get 5% to 20% more QPS when the memtable and level 0 is flushed. Details at https://gist.github.com/mdcallag/68052cdd36fe122354bc23ec337fb986 |
@siying suggested that MyRocks can for now issues a Flush() and compact all L0 files using CompactFiles() API. |
Siying pointed out that for MyRocks to know list of L0/L1 files from a CF, DB::GetColumnFamilyMetaData() can be used. Find files from there and call DB::CompactFiles() with those files. |
We have rocksdb_compact_cf variable to rebuild specific CF. We can add another command variable to flush MemTable and L0/L1 (or SQL function). |
Since RocksDB has block-cache, is it necessary to flush memtable and compact L0 sst files for read-only queries? Because there are only at most 4 sst files in L0. |
While working on this I think I have discovered a bug within RocksDB. The code changes are relatively straightforward and just get the column family meta data and call compactFiles(). Stacktrace: (looks like there is some issue with calling CompactFiles when there is a CompactionFilter enabled, the SuperVersion is not set correctly) @IslamAbdelRahman @siying do you mind taking a look? Can just pull the latest myrocks, apply my patch via |
Thanks @alxyang, it looks like an issue in rocksdb that happen when CompactionFilter is issued with CompactFiles() and the CompactionFilter is using DB::Get() inside. |
@zhangjinpeng1987 if the data working set is so small that it all cached in memory, RocksDB will lose B-tree because both read data from memory without compression, but RocksDB needs merge data from multiple levels, L0 files and memtables. In order to improve read-only workload, we can compact memtables and L0 files so we have less data to merge. |
…sion Summary: GetAndRefSuperVersion() should not be called again in the same thread before ReturnAndCleanupSuperVersion() is called. If we have a compaction filter that is using DB::Get, This will happen ``` CompactFiles() { GetAndRefSuperVersion() // -- first call .. CompactionFilter() { GetAndRefSuperVersion() // -- second call ReturnAndCleanupSuperVersion() } .. ReturnAndCleanupSuperVersion() } ``` We solve this issue in the same way Iterator is solving it, but using GetReferencedSuperVersion() This was discovered in facebook/mysql-5.6#427 by alxyang Closes #1803 Differential Revision: D4460155 Pulled By: IslamAbdelRahman fbshipit-source-id: 5e54322
…sion Summary: GetAndRefSuperVersion() should not be called again in the same thread before ReturnAndCleanupSuperVersion() is called. If we have a compaction filter that is using DB::Get, This will happen ``` CompactFiles() { GetAndRefSuperVersion() // -- first call .. CompactionFilter() { GetAndRefSuperVersion() // -- second call ReturnAndCleanupSuperVersion() } .. ReturnAndCleanupSuperVersion() } ``` We solve this issue in the same way Iterator is solving it, but using GetReferencedSuperVersion() This was discovered in facebook/mysql-5.6#427 by alxyang Closes facebook#1803 Differential Revision: D4460155 Pulled By: IslamAbdelRahman fbshipit-source-id: 5e54322
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at #427. update-submodule: rocksdb Closes #520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Github Author: Alex Yang <[email protected]> Github PR Sync: {sync, type="child", parent="github", parentrepo="facebook/mysql-5.6", parentprnum="520", parentprfbid="156908684811954"} Test Plan: Imported from GitHub, without a `Test Plan:` line. Reviewers: herman, jkedgar, svcscm Reviewed By: svcscm Subscribers: svcscm, [email protected] Differential Revision: https://phabricator.intern.facebook.com/D4509351 Signature: t1:4509351:1490814923:d177f0faf2cc11c4e76afd5399343a34c152fd74
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7 Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7 Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7 Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Upstream commit ID : fb-mysql-5.6.35/a44d6c287111c63d35fde0222adfebeb54d601c7 Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: 3f04f3c
One variant of this is an option to flush the memtable and merge L0 to L1 after at most N seconds when workload is read-mostly. The worst case is a read-only workload where the memtable flush and L0->L1 merge triggers are never reached. So all queries spend extra CPu going through the memtable and L0, when it would be better to pay the small/one-time cost of doing memtable flush and L0->L1 merge. |
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at #427. update-submodule: rocksdb Closes #520 Differential Revision: D4509351 Pulled By: alxyang fbshipit-source-id: dd3c711
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
Other things that can help if done adaptively by RocksDB depending on the workload are reducing the L0 trigger so there are fewer L0 SSTs, reducing memtable size. I think this is feasible and hope for progress. Otherwise I will continue mis-reporting perf results for MyRocks and RocksDB and I don't always have the time to fix my mistakes. But the real winners will be users. |
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at #427. update-submodule: rocksdb Closes #520 Differential Revision: D4509351 (44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 (facebook@44a522c) Pulled By: alxyang fbshipit-source-id: c5de1697c40
Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at #427. @update-submodule: rocksdb Closes #520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…na#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. @update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…book#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook#427. @update-submodule: rocksdb Closes facebook#520 Differential Revision: D4509351 Pulled By: alxyang
…na#520) Summary: This provides an option to flush memtable and remove all files from L0, which can be useful for lessening variance in benchmarking on read-only and read-heavy tests, in cases where the memtable isn't full and/or there aren't many files in L0, and no writes are occurring. See more details at facebook/mysql-5.6#427. @update-submodule: rocksdb Closes facebook/mysql-5.6#520 Differential Revision: D4509351 Pulled By: alxyang
The state of the LSM tree (data in memtable, #files in L0) is a significant source of variance for performance on read-only and read-heavy tests. This is much worse for read-only than for read-mostly workloads. Data in the memtable and files in L0 are overhead for read-only/mostly tests. When the memtable isn't full and when there aren't too many files in L0 then the LSM can stay in that state for a long time because there are no writes to trigger it to change. This is an issue for real workloads and for benchmarks.
I lost a few days debugging this problem recently. I know our users will also be confused by this and some will be disappointed by MyRocks performance. Part of the problem is that synthetic benchmarks are synthetic, but we can't get the world to stop running sysbench.
Can we solve this in two parts?
Someone suggested that CompactRange(nullptr, nullptr) flushes memtables and compacts L0. For step 1 we need a way to trigger that via SQL.
The text was updated successfully, but these errors were encountered: