CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
|
|
|
#include "db/compaction_picker.h"
|
2014-01-25 01:15:05 +01:00
|
|
|
|
2014-09-05 08:14:37 +02:00
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
2014-05-21 20:43:35 +02:00
|
|
|
#define __STDC_FORMAT_MACROS
|
2014-09-05 08:14:37 +02:00
|
|
|
#endif
|
|
|
|
|
2014-05-21 20:43:35 +02:00
|
|
|
#include <inttypes.h>
|
2014-01-25 01:15:05 +01:00
|
|
|
#include <limits>
|
2014-07-02 18:54:20 +02:00
|
|
|
#include "db/filename.h"
|
2014-03-10 06:01:13 +01:00
|
|
|
#include "util/log_buffer.h"
|
2014-01-17 21:46:06 +01:00
|
|
|
#include "util/statistics.h"
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
2014-08-07 19:05:04 +02:00
|
|
|
uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files) {
|
|
|
|
uint64_t sum = 0;
|
|
|
|
for (size_t i = 0; i < files.size() && files[i]; i++) {
|
|
|
|
sum += files[i]->compensated_file_size;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
namespace {
|
2014-07-02 20:40:57 +02:00
|
|
|
// Determine compression type, based on user options, level of the output
|
|
|
|
// file and whether compression is disabled.
|
|
|
|
// If enable_compression is false, then compression is always disabled no
|
|
|
|
// matter what the values of the other two parameters are.
|
|
|
|
// Otherwise, the compression type is determined based on options and level.
|
2014-10-02 01:19:16 +02:00
|
|
|
CompressionType GetCompressionType(
|
|
|
|
const ImmutableCFOptions& ioptions, int level,
|
|
|
|
const bool enable_compression = true) {
|
2014-07-02 20:40:57 +02:00
|
|
|
if (!enable_compression) {
|
|
|
|
// disable compression
|
|
|
|
return kNoCompression;
|
|
|
|
}
|
|
|
|
// If the use has specified a different compression level for each level,
|
2014-09-10 00:20:49 +02:00
|
|
|
// then pick the compression for that level.
|
2014-10-02 01:19:16 +02:00
|
|
|
if (!ioptions.compression_per_level.empty()) {
|
|
|
|
const int n = ioptions.compression_per_level.size() - 1;
|
2014-07-02 20:40:57 +02:00
|
|
|
// It is possible for level_ to be -1; in that case, we use level
|
|
|
|
// 0's compression. This occurs mostly in backwards compatibility
|
|
|
|
// situations when the builder doesn't know what level the file
|
2014-09-10 00:20:49 +02:00
|
|
|
// belongs to. Likewise, if level is beyond the end of the
|
2014-07-02 20:40:57 +02:00
|
|
|
// specified compression levels, use the last value.
|
2014-10-02 01:19:16 +02:00
|
|
|
return ioptions.compression_per_level[std::max(0, std::min(level, n))];
|
2014-07-02 20:40:57 +02:00
|
|
|
} else {
|
2014-10-02 01:19:16 +02:00
|
|
|
return ioptions.compression;
|
2014-07-02 20:40:57 +02:00
|
|
|
}
|
|
|
|
}
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-01-24 01:27:34 +01:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
CompactionPicker::CompactionPicker(const ImmutableCFOptions& ioptions,
|
2014-03-11 22:52:17 +01:00
|
|
|
const InternalKeyComparator* icmp)
|
2014-10-02 01:19:16 +02:00
|
|
|
: ioptions_(ioptions),
|
|
|
|
compactions_in_progress_(ioptions_.num_levels),
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
icmp_(icmp) {
|
|
|
|
}
|
|
|
|
|
|
|
|
CompactionPicker::~CompactionPicker() {}
|
|
|
|
|
|
|
|
void CompactionPicker::SizeBeingCompacted(std::vector<uint64_t>& sizes) {
|
|
|
|
for (int level = 0; level < NumberLevels() - 1; level++) {
|
|
|
|
uint64_t total = 0;
|
|
|
|
for (auto c : compactions_in_progress_[level]) {
|
|
|
|
assert(c->level() == level);
|
|
|
|
for (int i = 0; i < c->num_input_files(0); i++) {
|
2014-06-25 00:37:06 +02:00
|
|
|
total += c->input(0, i)->compensated_file_size;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sizes[level] = total;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear all files to indicate that they are not being compacted
|
|
|
|
// Delete this compaction from the list of running compactions.
|
|
|
|
void CompactionPicker::ReleaseCompactionFiles(Compaction* c, Status status) {
|
|
|
|
c->MarkFilesBeingCompacted(false);
|
|
|
|
compactions_in_progress_[c->level()].erase(c);
|
|
|
|
if (!status.ok()) {
|
|
|
|
c->ResetNextCompactionIndex();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompactionPicker::GetRange(const std::vector<FileMetaData*>& inputs,
|
|
|
|
InternalKey* smallest, InternalKey* largest) {
|
|
|
|
assert(!inputs.empty());
|
|
|
|
smallest->Clear();
|
|
|
|
largest->Clear();
|
|
|
|
for (size_t i = 0; i < inputs.size(); i++) {
|
|
|
|
FileMetaData* f = inputs[i];
|
|
|
|
if (i == 0) {
|
|
|
|
*smallest = f->smallest;
|
|
|
|
*largest = f->largest;
|
|
|
|
} else {
|
|
|
|
if (icmp_->Compare(f->smallest, *smallest) < 0) {
|
|
|
|
*smallest = f->smallest;
|
|
|
|
}
|
|
|
|
if (icmp_->Compare(f->largest, *largest) > 0) {
|
|
|
|
*largest = f->largest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompactionPicker::GetRange(const std::vector<FileMetaData*>& inputs1,
|
|
|
|
const std::vector<FileMetaData*>& inputs2,
|
|
|
|
InternalKey* smallest, InternalKey* largest) {
|
|
|
|
std::vector<FileMetaData*> all = inputs1;
|
|
|
|
all.insert(all.end(), inputs2.begin(), inputs2.end());
|
|
|
|
GetRange(all, smallest, largest);
|
|
|
|
}
|
|
|
|
|
2014-01-17 21:02:03 +01:00
|
|
|
bool CompactionPicker::ExpandWhileOverlapping(Compaction* c) {
|
Fix concurrency issue in CompactionPicker
Summary:
I am currently working on a project that uses RocksDB. While debugging some perf issues, I came up across interesting compaction concurrency issue. Namely, I had 15 idle threads and a good comapction to do, but CompactionPicker returned "Compaction nothing to do". Here's how Internal stats looked:
2014/08/22-08:08:04.551982 7fc7fc3f5700 ------- DUMPING STATS -------
2014/08/22-08:08:04.552000 7fc7fc3f5700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 7/5 353 1.0 0.0 0.0 0.0 2.3 2.3 0.0 0.0 0.0 9.4 0 0 0 0 247 46 5.359 8.53 1 8526.25
L1 2/2 86 1.3 2.6 1.9 0.7 2.6 1.9 2.7 1.3 24.3 24.0 39 19 71 52 109 11 9.938 0.00 0 0.00
L2 26/0 833 1.3 5.7 1.7 4.0 5.2 1.2 6.3 3.0 15.6 14.2 47 112 147 35 373 44 8.468 0.00 0 0.00
L3 12/0 505 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 0 0 0 0.000 0.00 0 0.00
Sum 47/7 1778 0.0 8.3 3.6 4.6 10.0 5.4 8.1 4.4 11.6 14.1 86 131 218 87 728 101 7.212 8.53 1 8526.25
Int 0/0 0 0.0 2.4 0.8 1.6 2.7 1.2 11.5 6.1 12.0 13.6 20 43 63 20 203 23 8.845 0.00 0 0.00
Flush(GB): accumulative 2.266, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 8.526 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 1 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 336.8 total, 60.4 interval
Cumulative writes: 61584000 writes, 6480589 batches, 9.5 writes per batch, 1.39 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11235257 writes, 1175050 batches, 9.6 writes per batch, 259.9 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
To see what happened, go here: https://github.com/facebook/rocksdb/blob/47b452cfcf9b1487d41f886a98bc0d6f95587e90/db/compaction_picker.cc#L430
* The for loop started with level 1, because it has the worst score.
* PickCompactionBySize on L429 returned nullptr because all files were being compacted
* ExpandWhileOverlapping(c) returned true (because that's what it does when it gets nullptr!?)
* for loop break-ed, never trying compactions for level 2 :( :(
This bug was present at least since January. I have no idea how we didn't find this sooner.
Test Plan:
Unit testing compaction picker is hard. I tested this by running my service and observing L0->L1 and L2->L3 compactions in parallel. However, for long-term, I opened the task #4968469. @yhchiang is currently refactoring CompactionPicker, hopefully the new version will be unit-testable ;)
Here's how my compactions look like after the patch:
2014/08/22-08:50:02.166699 7f3400ffb700 ------- DUMPING STATS -------
2014/08/22-08:50:02.166722 7f3400ffb700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 8/5 404 1.5 0.0 0.0 0.0 4.3 4.3 0.0 0.0 0.0 9.6 0 0 0 0 463 88 5.260 0.00 0 0.00
L1 2/2 60 0.9 4.8 3.9 0.8 4.7 3.9 2.4 1.2 23.9 23.6 80 23 131 108 204 19 10.747 0.00 0 0.00
L2 23/3 697 1.0 11.6 3.5 8.1 10.9 2.8 6.4 3.1 17.7 16.6 95 242 317 75 669 92 7.268 0.00 0 0.00
L3 58/14 2207 0.3 6.2 1.6 4.6 5.9 1.3 7.4 3.6 14.6 13.9 43 121 159 38 436 36 12.106 0.00 0 0.00
Sum 91/24 3368 0.0 22.5 9.1 13.5 25.8 12.4 11.2 6.0 13.0 14.9 218 386 607 221 1772 235 7.538 0.00 0 0.00
Int 0/0 0 0.0 3.2 0.9 2.3 3.6 1.3 15.3 8.0 12.4 13.7 24 66 89 23 266 27 9.838 0.00 0 0.00
Flush(GB): accumulative 4.336, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 0.000 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 0 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 577.7 total, 60.1 interval
Cumulative writes: 116960736 writes, 11966220 batches, 9.8 writes per batch, 2.64 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11643735 writes, 1206136 batches, 9.7 writes per batch, 269.2 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
Yay for concurrent L0->L1 and L2->L3 compactions!
Reviewers: sdong, yhchiang, ljin
Reviewed By: yhchiang
Subscribers: yhchiang, leveldb
Differential Revision: https://reviews.facebook.net/D22305
2014-08-22 20:32:40 +02:00
|
|
|
assert(c != nullptr);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// If inputs are empty then there is nothing to expand.
|
Fix concurrency issue in CompactionPicker
Summary:
I am currently working on a project that uses RocksDB. While debugging some perf issues, I came up across interesting compaction concurrency issue. Namely, I had 15 idle threads and a good comapction to do, but CompactionPicker returned "Compaction nothing to do". Here's how Internal stats looked:
2014/08/22-08:08:04.551982 7fc7fc3f5700 ------- DUMPING STATS -------
2014/08/22-08:08:04.552000 7fc7fc3f5700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 7/5 353 1.0 0.0 0.0 0.0 2.3 2.3 0.0 0.0 0.0 9.4 0 0 0 0 247 46 5.359 8.53 1 8526.25
L1 2/2 86 1.3 2.6 1.9 0.7 2.6 1.9 2.7 1.3 24.3 24.0 39 19 71 52 109 11 9.938 0.00 0 0.00
L2 26/0 833 1.3 5.7 1.7 4.0 5.2 1.2 6.3 3.0 15.6 14.2 47 112 147 35 373 44 8.468 0.00 0 0.00
L3 12/0 505 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 0 0 0 0.000 0.00 0 0.00
Sum 47/7 1778 0.0 8.3 3.6 4.6 10.0 5.4 8.1 4.4 11.6 14.1 86 131 218 87 728 101 7.212 8.53 1 8526.25
Int 0/0 0 0.0 2.4 0.8 1.6 2.7 1.2 11.5 6.1 12.0 13.6 20 43 63 20 203 23 8.845 0.00 0 0.00
Flush(GB): accumulative 2.266, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 8.526 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 1 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 336.8 total, 60.4 interval
Cumulative writes: 61584000 writes, 6480589 batches, 9.5 writes per batch, 1.39 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11235257 writes, 1175050 batches, 9.6 writes per batch, 259.9 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
To see what happened, go here: https://github.com/facebook/rocksdb/blob/47b452cfcf9b1487d41f886a98bc0d6f95587e90/db/compaction_picker.cc#L430
* The for loop started with level 1, because it has the worst score.
* PickCompactionBySize on L429 returned nullptr because all files were being compacted
* ExpandWhileOverlapping(c) returned true (because that's what it does when it gets nullptr!?)
* for loop break-ed, never trying compactions for level 2 :( :(
This bug was present at least since January. I have no idea how we didn't find this sooner.
Test Plan:
Unit testing compaction picker is hard. I tested this by running my service and observing L0->L1 and L2->L3 compactions in parallel. However, for long-term, I opened the task #4968469. @yhchiang is currently refactoring CompactionPicker, hopefully the new version will be unit-testable ;)
Here's how my compactions look like after the patch:
2014/08/22-08:50:02.166699 7f3400ffb700 ------- DUMPING STATS -------
2014/08/22-08:50:02.166722 7f3400ffb700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 8/5 404 1.5 0.0 0.0 0.0 4.3 4.3 0.0 0.0 0.0 9.6 0 0 0 0 463 88 5.260 0.00 0 0.00
L1 2/2 60 0.9 4.8 3.9 0.8 4.7 3.9 2.4 1.2 23.9 23.6 80 23 131 108 204 19 10.747 0.00 0 0.00
L2 23/3 697 1.0 11.6 3.5 8.1 10.9 2.8 6.4 3.1 17.7 16.6 95 242 317 75 669 92 7.268 0.00 0 0.00
L3 58/14 2207 0.3 6.2 1.6 4.6 5.9 1.3 7.4 3.6 14.6 13.9 43 121 159 38 436 36 12.106 0.00 0 0.00
Sum 91/24 3368 0.0 22.5 9.1 13.5 25.8 12.4 11.2 6.0 13.0 14.9 218 386 607 221 1772 235 7.538 0.00 0 0.00
Int 0/0 0 0.0 3.2 0.9 2.3 3.6 1.3 15.3 8.0 12.4 13.7 24 66 89 23 266 27 9.838 0.00 0 0.00
Flush(GB): accumulative 4.336, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 0.000 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 0 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 577.7 total, 60.1 interval
Cumulative writes: 116960736 writes, 11966220 batches, 9.8 writes per batch, 2.64 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11643735 writes, 1206136 batches, 9.7 writes per batch, 269.2 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
Yay for concurrent L0->L1 and L2->L3 compactions!
Reviewers: sdong, yhchiang, ljin
Reviewed By: yhchiang
Subscribers: yhchiang, leveldb
Differential Revision: https://reviews.facebook.net/D22305
2014-08-22 20:32:40 +02:00
|
|
|
if (c->inputs_[0].empty()) {
|
|
|
|
assert(c->inputs_[1].empty());
|
|
|
|
// This isn't good compaction
|
|
|
|
return false;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetOverlappingInputs will always do the right thing for level-0.
|
|
|
|
// So we don't need to do any expansion if level == 0.
|
|
|
|
if (c->level() == 0) {
|
2014-01-17 21:02:03 +01:00
|
|
|
return true;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const int level = c->level();
|
|
|
|
InternalKey smallest, largest;
|
|
|
|
|
|
|
|
// Keep expanding c->inputs_[0] until we are sure that there is a
|
|
|
|
// "clean cut" boundary between the files in input and the surrounding files.
|
|
|
|
// This will ensure that no parts of a key are lost during compaction.
|
|
|
|
int hint_index = -1;
|
|
|
|
size_t old_size;
|
|
|
|
do {
|
|
|
|
old_size = c->inputs_[0].size();
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, &smallest, &largest);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
c->inputs_[0].clear();
|
|
|
|
c->input_version_->GetOverlappingInputs(
|
2014-07-17 03:12:17 +02:00
|
|
|
level, &smallest, &largest, &c->inputs_[0].files,
|
|
|
|
hint_index, &hint_index);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
} while(c->inputs_[0].size() > old_size);
|
|
|
|
|
|
|
|
// Get the new range
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, &smallest, &largest);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// If, after the expansion, there are files that are already under
|
|
|
|
// compaction, then we must drop/cancel this compaction.
|
|
|
|
int parent_index = -1;
|
2014-03-20 00:01:25 +01:00
|
|
|
if (c->inputs_[0].empty()) {
|
2014-10-02 01:19:16 +02:00
|
|
|
Log(ioptions_.info_log,
|
2014-04-25 15:51:16 +02:00
|
|
|
"[%s] ExpandWhileOverlapping() failure because zero input files",
|
|
|
|
c->column_family_data()->GetName().c_str());
|
2014-03-20 00:01:25 +01:00
|
|
|
}
|
2014-07-17 03:12:17 +02:00
|
|
|
if (c->inputs_[0].empty() || FilesInCompaction(c->inputs_[0].files) ||
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
(c->level() != c->output_level() &&
|
|
|
|
ParentRangeInCompaction(c->input_version_, &smallest, &largest, level,
|
|
|
|
&parent_index))) {
|
|
|
|
c->inputs_[0].clear();
|
|
|
|
c->inputs_[1].clear();
|
2014-01-17 21:02:03 +01:00
|
|
|
return false;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
2014-01-17 21:02:03 +01:00
|
|
|
return true;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if any one of specified files are being compacted
|
|
|
|
bool CompactionPicker::FilesInCompaction(std::vector<FileMetaData*>& files) {
|
|
|
|
for (unsigned int i = 0; i < files.size(); i++) {
|
|
|
|
if (files[i]->being_compacted) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if any one of the parent files are being compacted
|
|
|
|
bool CompactionPicker::ParentRangeInCompaction(Version* version,
|
|
|
|
const InternalKey* smallest,
|
|
|
|
const InternalKey* largest,
|
|
|
|
int level, int* parent_index) {
|
|
|
|
std::vector<FileMetaData*> inputs;
|
|
|
|
assert(level + 1 < NumberLevels());
|
|
|
|
|
|
|
|
version->GetOverlappingInputs(level + 1, smallest, largest, &inputs,
|
|
|
|
*parent_index, parent_index);
|
|
|
|
return FilesInCompaction(inputs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populates the set of inputs from "level+1" that overlap with "level".
|
|
|
|
// Will also attempt to expand "level" if that doesn't expand "level+1"
|
|
|
|
// or cause "level" to include a file for compaction that has an overlapping
|
|
|
|
// user-key with another file.
|
2014-10-02 01:19:16 +02:00
|
|
|
void CompactionPicker::SetupOtherInputs(
|
|
|
|
const MutableCFOptions& mutable_cf_options, Compaction* c) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// If inputs are empty, then there is nothing to expand.
|
|
|
|
// If both input and output levels are the same, no need to consider
|
|
|
|
// files at level "level+1"
|
|
|
|
if (c->inputs_[0].empty() || c->level() == c->output_level()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int level = c->level();
|
|
|
|
InternalKey smallest, largest;
|
|
|
|
|
|
|
|
// Get the range one last time.
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, &smallest, &largest);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// Populate the set of next-level files (inputs_[1]) to include in compaction
|
2014-07-17 03:12:17 +02:00
|
|
|
c->input_version_->GetOverlappingInputs(
|
|
|
|
level + 1, &smallest, &largest,
|
|
|
|
&c->inputs_[1].files, c->parent_index_,
|
|
|
|
&c->parent_index_);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// Get entire range covered by compaction
|
|
|
|
InternalKey all_start, all_limit;
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, c->inputs_[1].files, &all_start, &all_limit);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// See if we can further grow the number of inputs in "level" without
|
|
|
|
// changing the number of "level+1" files we pick up. We also choose NOT
|
|
|
|
// to expand if this would cause "level" to include some entries for some
|
|
|
|
// user key, while excluding other entries for the same user key. This
|
|
|
|
// can happen when one user key spans multiple files.
|
|
|
|
if (!c->inputs_[1].empty()) {
|
|
|
|
std::vector<FileMetaData*> expanded0;
|
|
|
|
c->input_version_->GetOverlappingInputs(
|
|
|
|
level, &all_start, &all_limit, &expanded0, c->base_index_, nullptr);
|
2014-07-17 03:12:17 +02:00
|
|
|
const uint64_t inputs0_size = TotalCompensatedFileSize(c->inputs_[0].files);
|
|
|
|
const uint64_t inputs1_size = TotalCompensatedFileSize(c->inputs_[1].files);
|
2014-06-25 00:37:06 +02:00
|
|
|
const uint64_t expanded0_size = TotalCompensatedFileSize(expanded0);
|
2014-10-02 01:19:16 +02:00
|
|
|
uint64_t limit = mutable_cf_options.ExpandedCompactionByteSizeLimit(level);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (expanded0.size() > c->inputs_[0].size() &&
|
|
|
|
inputs1_size + expanded0_size < limit &&
|
|
|
|
!FilesInCompaction(expanded0) &&
|
|
|
|
!c->input_version_->HasOverlappingUserKey(&expanded0, level)) {
|
|
|
|
InternalKey new_start, new_limit;
|
|
|
|
GetRange(expanded0, &new_start, &new_limit);
|
|
|
|
std::vector<FileMetaData*> expanded1;
|
|
|
|
c->input_version_->GetOverlappingInputs(level + 1, &new_start, &new_limit,
|
|
|
|
&expanded1, c->parent_index_,
|
|
|
|
&c->parent_index_);
|
|
|
|
if (expanded1.size() == c->inputs_[1].size() &&
|
|
|
|
!FilesInCompaction(expanded1)) {
|
2014-10-02 01:19:16 +02:00
|
|
|
Log(ioptions_.info_log,
|
2014-06-28 01:01:59 +02:00
|
|
|
"[%s] Expanding@%d %zu+%zu (%" PRIu64 "+%" PRIu64
|
|
|
|
" bytes) to %zu+%zu (%" PRIu64 "+%" PRIu64 "bytes)\n",
|
|
|
|
c->column_family_data()->GetName().c_str(), level,
|
|
|
|
c->inputs_[0].size(), c->inputs_[1].size(), inputs0_size,
|
|
|
|
inputs1_size, expanded0.size(), expanded1.size(), expanded0_size,
|
|
|
|
inputs1_size);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
smallest = new_start;
|
|
|
|
largest = new_limit;
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files = expanded0;
|
|
|
|
c->inputs_[1].files = expanded1;
|
|
|
|
GetRange(c->inputs_[0].files, c->inputs_[1].files,
|
|
|
|
&all_start, &all_limit);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the set of grandparent files that overlap this compaction
|
|
|
|
// (parent == level+1; grandparent == level+2)
|
|
|
|
if (level + 2 < NumberLevels()) {
|
|
|
|
c->input_version_->GetOverlappingInputs(level + 2, &all_start, &all_limit,
|
|
|
|
&c->grandparents_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
Compaction* CompactionPicker::CompactRange(
|
|
|
|
const MutableCFOptions& mutable_cf_options, Version* version,
|
|
|
|
int input_level, int output_level, uint32_t output_path_id,
|
|
|
|
const InternalKey* begin, const InternalKey* end,
|
|
|
|
InternalKey** compaction_end) {
|
2014-05-21 20:43:35 +02:00
|
|
|
// CompactionPickerFIFO has its own implementation of compact range
|
2014-10-02 01:19:16 +02:00
|
|
|
assert(ioptions_.compaction_style != kCompactionStyleFIFO);
|
2014-05-21 20:43:35 +02:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
std::vector<FileMetaData*> inputs;
|
|
|
|
bool covering_the_whole_range = true;
|
|
|
|
|
|
|
|
// All files are 'overlapping' in universal style compaction.
|
|
|
|
// We have to compact the entire range in one shot.
|
2014-10-02 01:19:16 +02:00
|
|
|
if (ioptions_.compaction_style == kCompactionStyleUniversal) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
begin = nullptr;
|
|
|
|
end = nullptr;
|
|
|
|
}
|
|
|
|
version->GetOverlappingInputs(input_level, begin, end, &inputs);
|
|
|
|
if (inputs.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Avoid compacting too much in one shot in case the range is large.
|
|
|
|
// But we cannot do this for level-0 since level-0 files can overlap
|
|
|
|
// and we must not pick one file and drop another older file if the
|
|
|
|
// two files overlap.
|
|
|
|
if (input_level > 0) {
|
2014-10-02 01:19:16 +02:00
|
|
|
const uint64_t limit = mutable_cf_options.MaxFileSizeForLevel(input_level) *
|
|
|
|
mutable_cf_options.source_compaction_factor;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
uint64_t total = 0;
|
|
|
|
for (size_t i = 0; i + 1 < inputs.size(); ++i) {
|
2014-06-25 00:37:06 +02:00
|
|
|
uint64_t s = inputs[i]->compensated_file_size;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
total += s;
|
|
|
|
if (total >= limit) {
|
|
|
|
**compaction_end = inputs[i + 1]->smallest;
|
|
|
|
covering_the_whole_range = false;
|
|
|
|
inputs.resize(i + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-02 01:19:16 +02:00
|
|
|
assert(output_path_id < static_cast<uint32_t>(ioptions_.db_paths.size()));
|
2014-07-17 02:39:18 +02:00
|
|
|
Compaction* c = new Compaction(
|
2014-10-02 01:19:16 +02:00
|
|
|
version, input_level, output_level,
|
|
|
|
mutable_cf_options.MaxFileSizeForLevel(output_level),
|
|
|
|
mutable_cf_options.MaxGrandParentOverlapBytes(input_level),
|
|
|
|
output_path_id,
|
|
|
|
GetCompressionType(ioptions_, output_level));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files = inputs;
|
2014-01-17 21:02:03 +01:00
|
|
|
if (ExpandWhileOverlapping(c) == false) {
|
|
|
|
delete c;
|
2014-10-02 01:19:16 +02:00
|
|
|
Log(ioptions_.info_log,
|
2014-04-25 15:51:16 +02:00
|
|
|
"[%s] Could not compact due to expansion failure.\n",
|
2014-10-28 17:59:56 +01:00
|
|
|
version->cfd()->GetName().c_str());
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
SetupOtherInputs(mutable_cf_options, c);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
if (covering_the_whole_range) {
|
|
|
|
*compaction_end = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// These files that are to be manaully compacted do not trample
|
|
|
|
// upon other files because manual compactions are processed when
|
|
|
|
// the system has a max of 1 background compaction thread.
|
|
|
|
c->MarkFilesBeingCompacted(true);
|
|
|
|
|
|
|
|
// Is this compaction creating a file at the bottommost level
|
|
|
|
c->SetupBottomMostLevel(true);
|
2014-02-12 21:24:18 +01:00
|
|
|
|
|
|
|
c->is_manual_compaction_ = true;
|
2014-10-02 01:19:16 +02:00
|
|
|
c->mutable_cf_options_ = mutable_cf_options;
|
2014-02-12 21:24:18 +01:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
Compaction* LevelCompactionPicker::PickCompaction(
|
|
|
|
const MutableCFOptions& mutable_cf_options,
|
|
|
|
Version* version, LogBuffer* log_buffer) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
Compaction* c = nullptr;
|
|
|
|
int level = -1;
|
|
|
|
|
2014-03-20 00:52:26 +01:00
|
|
|
// Compute the compactions needed. It is better to do it here
|
|
|
|
// and also in LogAndApply(), otherwise the values could be stale.
|
|
|
|
std::vector<uint64_t> size_being_compacted(NumberLevels() - 1);
|
|
|
|
SizeBeingCompacted(size_being_compacted);
|
2014-10-02 01:19:16 +02:00
|
|
|
version->ComputeCompactionScore(mutable_cf_options, size_being_compacted);
|
2014-03-20 00:52:26 +01:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// We prefer compactions triggered by too much data in a level over
|
|
|
|
// the compactions triggered by seeks.
|
|
|
|
//
|
|
|
|
// Find the compactions by size on all levels.
|
|
|
|
for (int i = 0; i < NumberLevels() - 1; i++) {
|
2014-10-28 18:00:51 +01:00
|
|
|
double score = version->CompactionScore(i);
|
|
|
|
assert(i == 0 || score <= version->CompactionScore(i - 1));
|
|
|
|
level = version->CompactionScoreLevel(i);
|
|
|
|
if (score >= 1) {
|
|
|
|
c = PickCompactionBySize(mutable_cf_options, version, level, score);
|
Fix concurrency issue in CompactionPicker
Summary:
I am currently working on a project that uses RocksDB. While debugging some perf issues, I came up across interesting compaction concurrency issue. Namely, I had 15 idle threads and a good comapction to do, but CompactionPicker returned "Compaction nothing to do". Here's how Internal stats looked:
2014/08/22-08:08:04.551982 7fc7fc3f5700 ------- DUMPING STATS -------
2014/08/22-08:08:04.552000 7fc7fc3f5700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 7/5 353 1.0 0.0 0.0 0.0 2.3 2.3 0.0 0.0 0.0 9.4 0 0 0 0 247 46 5.359 8.53 1 8526.25
L1 2/2 86 1.3 2.6 1.9 0.7 2.6 1.9 2.7 1.3 24.3 24.0 39 19 71 52 109 11 9.938 0.00 0 0.00
L2 26/0 833 1.3 5.7 1.7 4.0 5.2 1.2 6.3 3.0 15.6 14.2 47 112 147 35 373 44 8.468 0.00 0 0.00
L3 12/0 505 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 0 0 0 0.000 0.00 0 0.00
Sum 47/7 1778 0.0 8.3 3.6 4.6 10.0 5.4 8.1 4.4 11.6 14.1 86 131 218 87 728 101 7.212 8.53 1 8526.25
Int 0/0 0 0.0 2.4 0.8 1.6 2.7 1.2 11.5 6.1 12.0 13.6 20 43 63 20 203 23 8.845 0.00 0 0.00
Flush(GB): accumulative 2.266, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 8.526 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 1 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 336.8 total, 60.4 interval
Cumulative writes: 61584000 writes, 6480589 batches, 9.5 writes per batch, 1.39 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11235257 writes, 1175050 batches, 9.6 writes per batch, 259.9 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
To see what happened, go here: https://github.com/facebook/rocksdb/blob/47b452cfcf9b1487d41f886a98bc0d6f95587e90/db/compaction_picker.cc#L430
* The for loop started with level 1, because it has the worst score.
* PickCompactionBySize on L429 returned nullptr because all files were being compacted
* ExpandWhileOverlapping(c) returned true (because that's what it does when it gets nullptr!?)
* for loop break-ed, never trying compactions for level 2 :( :(
This bug was present at least since January. I have no idea how we didn't find this sooner.
Test Plan:
Unit testing compaction picker is hard. I tested this by running my service and observing L0->L1 and L2->L3 compactions in parallel. However, for long-term, I opened the task #4968469. @yhchiang is currently refactoring CompactionPicker, hopefully the new version will be unit-testable ;)
Here's how my compactions look like after the patch:
2014/08/22-08:50:02.166699 7f3400ffb700 ------- DUMPING STATS -------
2014/08/22-08:50:02.166722 7f3400ffb700
** Compaction Stats [default] **
Level Files Size(MB) Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) RW-Amp W-Amp Rd(MB/s) Wr(MB/s) Rn(cnt) Rnp1(cnt) Wnp1(cnt) Wnew(cnt) Comp(sec) Comp(cnt) Avg(sec) Stall(sec) Stall(cnt) Avg(ms)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
L0 8/5 404 1.5 0.0 0.0 0.0 4.3 4.3 0.0 0.0 0.0 9.6 0 0 0 0 463 88 5.260 0.00 0 0.00
L1 2/2 60 0.9 4.8 3.9 0.8 4.7 3.9 2.4 1.2 23.9 23.6 80 23 131 108 204 19 10.747 0.00 0 0.00
L2 23/3 697 1.0 11.6 3.5 8.1 10.9 2.8 6.4 3.1 17.7 16.6 95 242 317 75 669 92 7.268 0.00 0 0.00
L3 58/14 2207 0.3 6.2 1.6 4.6 5.9 1.3 7.4 3.6 14.6 13.9 43 121 159 38 436 36 12.106 0.00 0 0.00
Sum 91/24 3368 0.0 22.5 9.1 13.5 25.8 12.4 11.2 6.0 13.0 14.9 218 386 607 221 1772 235 7.538 0.00 0 0.00
Int 0/0 0 0.0 3.2 0.9 2.3 3.6 1.3 15.3 8.0 12.4 13.7 24 66 89 23 266 27 9.838 0.00 0 0.00
Flush(GB): accumulative 4.336, interval 0.444
Stalls(secs): 0.000 level0_slowdown, 0.000 level0_numfiles, 0.000 memtable_compaction, 0.000 leveln_slowdown_soft, 0.000 leveln_slowdown_hard
Stalls(count): 0 level0_slowdown, 0 level0_numfiles, 0 memtable_compaction, 0 leveln_slowdown_soft, 0 leveln_slowdown_hard
** DB Stats **
Uptime(secs): 577.7 total, 60.1 interval
Cumulative writes: 116960736 writes, 11966220 batches, 9.8 writes per batch, 2.64 GB user ingest
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 GB written
Interval writes: 11643735 writes, 1206136 batches, 9.7 writes per batch, 269.2 MB user ingest
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, 0.00 MB written
Yay for concurrent L0->L1 and L2->L3 compactions!
Reviewers: sdong, yhchiang, ljin
Reviewed By: yhchiang
Subscribers: yhchiang, leveldb
Differential Revision: https://reviews.facebook.net/D22305
2014-08-22 20:32:40 +02:00
|
|
|
if (c == nullptr || ExpandWhileOverlapping(c) == false) {
|
2014-01-17 21:02:03 +01:00
|
|
|
delete c;
|
|
|
|
c = nullptr;
|
|
|
|
} else {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Two level 0 compaction won't run at the same time, so don't need to worry
|
|
|
|
// about files on level 0 being compacted.
|
|
|
|
if (level == 0) {
|
|
|
|
assert(compactions_in_progress_[0].empty());
|
|
|
|
InternalKey smallest, largest;
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, &smallest, &largest);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// Note that the next call will discard the file we placed in
|
|
|
|
// c->inputs_[0] earlier and replace it with an overlapping set
|
|
|
|
// which will include the picked file.
|
|
|
|
c->inputs_[0].clear();
|
|
|
|
c->input_version_->GetOverlappingInputs(0, &smallest, &largest,
|
2014-07-17 03:12:17 +02:00
|
|
|
&c->inputs_[0].files);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// If we include more L0 files in the same compaction run it can
|
|
|
|
// cause the 'smallest' and 'largest' key to get extended to a
|
|
|
|
// larger range. So, re-invoke GetRange to get the new key range
|
2014-07-17 03:12:17 +02:00
|
|
|
GetRange(c->inputs_[0].files, &smallest, &largest);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (ParentRangeInCompaction(c->input_version_, &smallest, &largest, level,
|
|
|
|
&c->parent_index_)) {
|
|
|
|
delete c;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
assert(!c->inputs_[0].empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup "level+1" files (inputs_[1])
|
2014-10-02 01:19:16 +02:00
|
|
|
SetupOtherInputs(mutable_cf_options, c);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// mark all the files that are being compacted
|
|
|
|
c->MarkFilesBeingCompacted(true);
|
|
|
|
|
|
|
|
// Is this compaction creating a file at the bottommost level
|
|
|
|
c->SetupBottomMostLevel(false);
|
|
|
|
|
|
|
|
// remember this currently undergoing compaction
|
|
|
|
compactions_in_progress_[level].insert(c);
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
c->mutable_cf_options_ = mutable_cf_options;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
Compaction* LevelCompactionPicker::PickCompactionBySize(
|
|
|
|
const MutableCFOptions& mutable_cf_options,
|
|
|
|
Version* version, int level, double score) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
Compaction* c = nullptr;
|
|
|
|
|
|
|
|
// level 0 files are overlapping. So we cannot pick more
|
|
|
|
// than one concurrent compactions at this level. This
|
|
|
|
// could be made better by looking at key-ranges that are
|
|
|
|
// being compacted at level 0.
|
|
|
|
if (level == 0 && compactions_in_progress_[level].size() == 1) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(level >= 0);
|
|
|
|
assert(level + 1 < NumberLevels());
|
2014-10-02 01:19:16 +02:00
|
|
|
c = new Compaction(version, level, level + 1,
|
|
|
|
mutable_cf_options.MaxFileSizeForLevel(level + 1),
|
|
|
|
mutable_cf_options.MaxGrandParentOverlapBytes(level), 0,
|
|
|
|
GetCompressionType(ioptions_, level + 1));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
c->score_ = score;
|
|
|
|
|
|
|
|
// Pick the largest file in this level that is not already
|
|
|
|
// being compacted
|
2014-10-28 18:00:51 +01:00
|
|
|
const std::vector<int>& file_size = version->FilesBySize(level);
|
|
|
|
const std::vector<FileMetaData*>& level_files = version->LevelFiles(level);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// record the first file that is not yet compacted
|
|
|
|
int nextIndex = -1;
|
|
|
|
|
2014-10-28 17:59:56 +01:00
|
|
|
for (unsigned int i = version->NextCompactionIndex(level);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
i < file_size.size(); i++) {
|
|
|
|
int index = file_size[i];
|
2014-10-28 18:00:51 +01:00
|
|
|
FileMetaData* f = level_files[index];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-07-09 21:46:08 +02:00
|
|
|
// Check to verify files are arranged in descending compensated size.
|
2014-06-25 00:37:06 +02:00
|
|
|
assert((i == file_size.size() - 1) ||
|
2014-10-28 18:00:51 +01:00
|
|
|
(i >= Version::kNumberFilesToSort - 1) ||
|
2014-06-25 00:37:06 +02:00
|
|
|
(f->compensated_file_size >=
|
2014-10-28 18:00:51 +01:00
|
|
|
level_files[file_size[i + 1]]->compensated_file_size));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// do not pick a file to compact if it is being compacted
|
|
|
|
// from n-1 level.
|
|
|
|
if (f->being_compacted) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remember the startIndex for the next call to PickCompaction
|
|
|
|
if (nextIndex == -1) {
|
|
|
|
nextIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not pick this file if its parents at level+1 are being compacted.
|
|
|
|
// Maybe we can avoid redoing this work in SetupOtherInputs
|
|
|
|
int parent_index = -1;
|
2014-10-28 17:59:56 +01:00
|
|
|
if (ParentRangeInCompaction(version, &f->smallest, &f->largest,
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
level, &parent_index)) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files.push_back(f);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
c->base_index_ = index;
|
|
|
|
c->parent_index_ = parent_index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c->inputs_[0].empty()) {
|
|
|
|
delete c;
|
|
|
|
c = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// store where to start the iteration in the next call to PickCompaction
|
2014-10-28 17:59:56 +01:00
|
|
|
version->SetNextCompactionIndex(level, nextIndex);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Universal style of compaction. Pick files that are contiguous in
|
|
|
|
// time-range to compact.
|
|
|
|
//
|
2014-10-02 01:19:16 +02:00
|
|
|
Compaction* UniversalCompactionPicker::PickCompaction(
|
|
|
|
const MutableCFOptions& mutable_cf_options,
|
|
|
|
Version* version, LogBuffer* log_buffer) {
|
2014-10-28 18:00:51 +01:00
|
|
|
const int kLevel0 = 0;
|
|
|
|
double score = version->CompactionScore(kLevel0);
|
|
|
|
const std::vector<FileMetaData*>& level_files = version->LevelFiles(kLevel0);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-10-28 18:00:51 +01:00
|
|
|
if ((level_files.size() <
|
2014-10-02 01:19:16 +02:00
|
|
|
(unsigned int)mutable_cf_options.level0_file_num_compaction_trigger)) {
|
2014-04-25 15:51:16 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: nothing to do\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str());
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
Version::FileSummaryStorage tmp;
|
2014-09-23 22:43:03 +02:00
|
|
|
LogToBuffer(log_buffer, 3072, "[%s] Universal: candidate files(%zu): %s\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), level_files.size(),
|
|
|
|
version->LevelFileSummary(&tmp, kLevel0));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// Check for size amplification first.
|
2013-12-23 17:54:50 +01:00
|
|
|
Compaction* c;
|
2014-10-02 01:19:16 +02:00
|
|
|
if ((c = PickCompactionUniversalSizeAmp(
|
|
|
|
mutable_cf_options, version, score, log_buffer)) != nullptr) {
|
2014-04-25 15:51:16 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: compacting for size amp\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str());
|
2013-12-23 17:54:50 +01:00
|
|
|
} else {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// Size amplification is within limits. Try reducing read
|
|
|
|
// amplification while maintaining file size ratios.
|
2014-10-02 01:19:16 +02:00
|
|
|
unsigned int ratio = ioptions_.compaction_options_universal.size_ratio;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
if ((c = PickCompactionUniversalReadAmp(
|
|
|
|
mutable_cf_options, version, score, ratio,
|
|
|
|
UINT_MAX, log_buffer)) != nullptr) {
|
2014-04-25 15:51:16 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: compacting for size ratio\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str());
|
2013-12-23 17:54:50 +01:00
|
|
|
} else {
|
|
|
|
// Size amplification and file size ratios are within configured limits.
|
|
|
|
// If max read amplification is exceeding configured limits, then force
|
|
|
|
// compaction without looking at filesize ratios and try to reduce
|
|
|
|
// the number of files to fewer than level0_file_num_compaction_trigger.
|
2014-10-28 18:00:51 +01:00
|
|
|
unsigned int num_files = level_files.size() -
|
2014-10-02 01:19:16 +02:00
|
|
|
mutable_cf_options.level0_file_num_compaction_trigger;
|
Buffer info logs when picking compactions and write them out after releasing the mutex
Summary: Now while the background thread is picking compactions, it writes out multiple info_logs, especially for universal compaction, which introduces a chance of waiting log writing in mutex, which is bad. To remove this risk, write all those info logs to a buffer and flush it after releasing the mutex.
Test Plan:
make all check
check the log lines while running some tests that trigger compactions.
Reviewers: haobo, igor, dhruba
Reviewed By: dhruba
CC: i.am.jin.lei, dhruba, yhchiang, leveldb, nkg-
Differential Revision: https://reviews.facebook.net/D16515
2014-03-04 23:32:55 +01:00
|
|
|
if ((c = PickCompactionUniversalReadAmp(
|
2014-10-02 01:19:16 +02:00
|
|
|
mutable_cf_options, version, score, UINT_MAX,
|
|
|
|
num_files, log_buffer)) != nullptr) {
|
2014-10-24 00:40:20 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: compacting for file num -- %u\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), num_files);
|
2013-12-23 17:54:50 +01:00
|
|
|
}
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (c == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-10-28 18:00:51 +01:00
|
|
|
assert(c->inputs_[kLevel0].size() > 1);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// validate that all the chosen files are non overlapping in time
|
|
|
|
FileMetaData* newerfile __attribute__((unused)) = nullptr;
|
2014-10-28 18:00:51 +01:00
|
|
|
for (unsigned int i = 0; i < c->inputs_[kLevel0].size(); i++) {
|
|
|
|
FileMetaData* f = c->inputs_[kLevel0][i];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
assert (f->smallest_seqno <= f->largest_seqno);
|
|
|
|
assert(newerfile == nullptr ||
|
|
|
|
newerfile->smallest_seqno > f->largest_seqno);
|
|
|
|
newerfile = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the earliest file part of this compaction?
|
2014-10-28 18:00:51 +01:00
|
|
|
FileMetaData* last_file = level_files.back();
|
|
|
|
c->bottommost_level_ = c->inputs_[kLevel0].files.back() == last_file;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-03-11 22:52:17 +01:00
|
|
|
// update statistics
|
2014-10-02 01:19:16 +02:00
|
|
|
MeasureTime(ioptions_.statistics,
|
2014-10-28 18:00:51 +01:00
|
|
|
NUM_FILES_IN_SINGLE_COMPACTION, c->inputs_[kLevel0].size());
|
2014-03-11 22:52:17 +01:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// mark all the files that are being compacted
|
|
|
|
c->MarkFilesBeingCompacted(true);
|
|
|
|
|
|
|
|
// remember this currently undergoing compaction
|
2014-10-28 18:00:51 +01:00
|
|
|
compactions_in_progress_[kLevel0].insert(c);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// Record whether this compaction includes all sst files.
|
|
|
|
// For now, it is only relevant in universal compaction mode.
|
2014-10-28 18:00:51 +01:00
|
|
|
c->is_full_compaction_ = (c->inputs_[kLevel0].size() == level_files.size());
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
c->mutable_cf_options_ = mutable_cf_options;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
uint32_t UniversalCompactionPicker::GetPathId(
|
|
|
|
const ImmutableCFOptions& ioptions, uint64_t file_size) {
|
2014-07-15 00:34:30 +02:00
|
|
|
// Two conditions need to be satisfied:
|
|
|
|
// (1) the target path needs to be able to hold the file's size
|
|
|
|
// (2) Total size left in this and previous paths need to be not
|
|
|
|
// smaller than expected future file size before this new file is
|
|
|
|
// compacted, which is estimated based on size_ratio.
|
|
|
|
// For example, if now we are compacting files of size (1, 1, 2, 4, 8),
|
|
|
|
// we will make sure the target file, probably with size of 16, will be
|
|
|
|
// placed in a path so that eventually when new files are generated and
|
|
|
|
// compacted to (1, 1, 2, 4, 8, 16), all those files can be stored in or
|
|
|
|
// before the path we chose.
|
|
|
|
//
|
|
|
|
// TODO(sdong): now the case of multiple column families is not
|
|
|
|
// considered in this algorithm. So the target size can be violated in
|
|
|
|
// that case. We need to improve it.
|
|
|
|
uint64_t accumulated_size = 0;
|
2014-10-02 01:19:16 +02:00
|
|
|
uint64_t future_size = file_size *
|
|
|
|
(100 - ioptions.compaction_options_universal.size_ratio) / 100;
|
2014-07-15 00:34:30 +02:00
|
|
|
uint32_t p = 0;
|
2014-10-02 01:19:16 +02:00
|
|
|
for (; p < ioptions.db_paths.size() - 1; p++) {
|
|
|
|
uint64_t target_size = ioptions.db_paths[p].target_size;
|
2014-07-15 00:34:30 +02:00
|
|
|
if (target_size > file_size &&
|
|
|
|
accumulated_size + (target_size - file_size) > future_size) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
accumulated_size += target_size;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
//
|
|
|
|
// Consider compaction files based on their size differences with
|
|
|
|
// the next file in time order.
|
|
|
|
//
|
|
|
|
Compaction* UniversalCompactionPicker::PickCompactionUniversalReadAmp(
|
2014-10-02 01:19:16 +02:00
|
|
|
const MutableCFOptions& mutable_cf_options, Version* version,
|
|
|
|
double score, unsigned int ratio,
|
Buffer info logs when picking compactions and write them out after releasing the mutex
Summary: Now while the background thread is picking compactions, it writes out multiple info_logs, especially for universal compaction, which introduces a chance of waiting log writing in mutex, which is bad. To remove this risk, write all those info logs to a buffer and flush it after releasing the mutex.
Test Plan:
make all check
check the log lines while running some tests that trigger compactions.
Reviewers: haobo, igor, dhruba
Reviewed By: dhruba
CC: i.am.jin.lei, dhruba, yhchiang, leveldb, nkg-
Differential Revision: https://reviews.facebook.net/D16515
2014-03-04 23:32:55 +01:00
|
|
|
unsigned int max_number_of_files_to_compact, LogBuffer* log_buffer) {
|
2014-10-28 18:00:51 +01:00
|
|
|
const int kLevel0 = 0;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
unsigned int min_merge_width =
|
2014-10-02 01:19:16 +02:00
|
|
|
ioptions_.compaction_options_universal.min_merge_width;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
unsigned int max_merge_width =
|
2014-10-02 01:19:16 +02:00
|
|
|
ioptions_.compaction_options_universal.max_merge_width;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// The files are sorted from newest first to oldest last.
|
2014-10-28 18:00:51 +01:00
|
|
|
const auto& files = version->LevelFiles(kLevel0);
|
2014-07-01 08:55:04 +02:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
FileMetaData* f = nullptr;
|
|
|
|
bool done = false;
|
|
|
|
int start_index = 0;
|
2014-04-03 20:45:44 +02:00
|
|
|
unsigned int candidate_count = 0;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
unsigned int max_files_to_compact = std::min(max_merge_width,
|
|
|
|
max_number_of_files_to_compact);
|
|
|
|
min_merge_width = std::max(min_merge_width, 2U);
|
|
|
|
|
|
|
|
// Considers a candidate file only if it is smaller than the
|
|
|
|
// total size accumulated so far.
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int loop = 0; loop < files.size(); loop++) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
candidate_count = 0;
|
|
|
|
|
|
|
|
// Skip files that are already being compacted
|
2014-07-01 08:55:04 +02:00
|
|
|
for (f = nullptr; loop < files.size(); loop++) {
|
|
|
|
f = files[loop];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
if (!f->being_compacted) {
|
|
|
|
candidate_count = 1;
|
|
|
|
break;
|
|
|
|
}
|
2014-06-28 01:01:59 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: file %" PRIu64
|
|
|
|
"[%d] being compacted, skipping",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), f->fd.GetNumber(), loop);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
f = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This file is not being compacted. Consider it as the
|
|
|
|
// first candidate to be compacted.
|
2014-06-25 00:37:06 +02:00
|
|
|
uint64_t candidate_size = f != nullptr? f->compensated_file_size : 0;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (f != nullptr) {
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(f->fd.GetNumber(), f->fd.GetPathId(), file_num_buf,
|
|
|
|
sizeof(file_num_buf));
|
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: Possible candidate file %s[%d].",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), file_num_buf, loop);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the suceeding files need compaction.
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int i = loop + 1;
|
|
|
|
candidate_count < max_files_to_compact && i < files.size(); i++) {
|
|
|
|
FileMetaData* f = files[i];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (f->being_compacted) {
|
|
|
|
break;
|
|
|
|
}
|
2013-12-24 10:09:09 +01:00
|
|
|
// Pick files if the total/last candidate file size (increased by the
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// specified ratio) is still larger than the next candidate file.
|
2013-12-24 10:09:09 +01:00
|
|
|
// candidate_size is the total size of files picked so far with the
|
|
|
|
// default kCompactionStopStyleTotalSize; with
|
|
|
|
// kCompactionStopStyleSimilarSize, it's simply the size of the last
|
|
|
|
// picked file.
|
2014-09-26 23:15:09 +02:00
|
|
|
double sz = candidate_size * (100.0 + ratio) / 100.0;
|
|
|
|
if (sz < static_cast<double>(f->fd.GetFileSize())) {
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
break;
|
2014-03-05 21:47:44 +01:00
|
|
|
}
|
2014-10-02 01:19:16 +02:00
|
|
|
if (ioptions_.compaction_options_universal.stop_style ==
|
|
|
|
kCompactionStopStyleSimilarSize) {
|
2013-12-24 10:09:09 +01:00
|
|
|
// Similar-size stopping rule: also check the last picked file isn't
|
|
|
|
// far larger than the next candidate file.
|
2014-09-26 23:15:09 +02:00
|
|
|
sz = (f->fd.GetFileSize() * (100.0 + ratio)) / 100.0;
|
|
|
|
if (sz < static_cast<double>(candidate_size)) {
|
2013-12-24 10:09:09 +01:00
|
|
|
// If the small file we've encountered begins a run of similar-size
|
|
|
|
// files, we'll pick them up on a future iteration of the outer
|
|
|
|
// loop. If it's some lonely straggler, it'll eventually get picked
|
|
|
|
// by the last-resort read amp strategy which disregards size ratios.
|
|
|
|
break;
|
|
|
|
}
|
2014-06-25 00:37:06 +02:00
|
|
|
candidate_size = f->compensated_file_size;
|
2013-12-24 10:09:09 +01:00
|
|
|
} else { // default kCompactionStopStyleTotalSize
|
2014-06-25 00:37:06 +02:00
|
|
|
candidate_size += f->compensated_file_size;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
candidate_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Found a series of consecutive files that need compaction.
|
|
|
|
if (candidate_count >= (unsigned int)min_merge_width) {
|
|
|
|
start_index = loop;
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
for (unsigned int i = loop;
|
2014-07-01 08:55:04 +02:00
|
|
|
i < loop + candidate_count && i < files.size(); i++) {
|
|
|
|
FileMetaData* f = files[i];
|
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: Skipping file %" PRIu64
|
|
|
|
"[%d] with size %" PRIu64
|
|
|
|
" (compensated size %" PRIu64 ") %d\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), f->fd.GetNumber(), i,
|
2014-07-01 08:55:04 +02:00
|
|
|
f->fd.GetFileSize(), f->compensated_file_size,
|
|
|
|
f->being_compacted);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!done || candidate_count <= 1) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
unsigned int first_index_after = start_index + candidate_count;
|
|
|
|
// Compression is enabled if files compacted earlier already reached
|
|
|
|
// size ratio of compression.
|
|
|
|
bool enable_compression = true;
|
|
|
|
int ratio_to_compress =
|
2014-10-02 01:19:16 +02:00
|
|
|
ioptions_.compaction_options_universal.compression_size_percent;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (ratio_to_compress >= 0) {
|
2014-10-28 18:00:51 +01:00
|
|
|
uint64_t total_size = version->NumLevelBytes(kLevel0);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
uint64_t older_file_size = 0;
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int i = files.size() - 1;
|
|
|
|
i >= first_index_after; i--) {
|
|
|
|
older_file_size += files[i]->fd.GetFileSize();
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (older_file_size * 100L >= total_size * (long) ratio_to_compress) {
|
|
|
|
enable_compression = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 00:34:30 +02:00
|
|
|
|
|
|
|
uint64_t estimated_total_size = 0;
|
|
|
|
for (unsigned int i = 0; i < first_index_after; i++) {
|
|
|
|
estimated_total_size += files[i]->fd.GetFileSize();
|
|
|
|
}
|
2014-10-02 01:19:16 +02:00
|
|
|
uint32_t path_id = GetPathId(ioptions_, estimated_total_size);
|
2014-07-15 00:34:30 +02:00
|
|
|
|
2014-10-28 18:00:51 +01:00
|
|
|
Compaction* c = new Compaction(version, kLevel0, kLevel0,
|
|
|
|
mutable_cf_options.MaxFileSizeForLevel(kLevel0),
|
|
|
|
LLONG_MAX, path_id, GetCompressionType(ioptions_, kLevel0,
|
2014-10-02 01:19:16 +02:00
|
|
|
enable_compression));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
c->score_ = score;
|
|
|
|
|
|
|
|
for (unsigned int i = start_index; i < first_index_after; i++) {
|
2014-10-28 18:00:51 +01:00
|
|
|
FileMetaData* f = files[i];
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files.push_back(f);
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(f->fd.GetNumber(), f->fd.GetPathId(), file_num_buf,
|
|
|
|
sizeof(file_num_buf));
|
2014-06-25 00:37:06 +02:00
|
|
|
LogToBuffer(log_buffer,
|
2014-07-02 18:54:20 +02:00
|
|
|
"[%s] Universal: Picking file %s[%d] "
|
2014-06-25 00:37:06 +02:00
|
|
|
"with size %" PRIu64 " (compensated size %" PRIu64 ")\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), file_num_buf, i,
|
2014-08-13 20:57:40 +02:00
|
|
|
f->fd.GetFileSize(), f->compensated_file_size);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Look at overall size amplification. If size amplification
|
|
|
|
// exceeeds the configured value, then do a compaction
|
|
|
|
// of the candidate files all the way upto the earliest
|
|
|
|
// base file (overrides configured values of file-size ratios,
|
|
|
|
// min_merge_width and max_merge_width).
|
|
|
|
//
|
|
|
|
Compaction* UniversalCompactionPicker::PickCompactionUniversalSizeAmp(
|
2014-10-02 01:19:16 +02:00
|
|
|
const MutableCFOptions& mutable_cf_options, Version* version,
|
|
|
|
double score, LogBuffer* log_buffer) {
|
2014-10-28 18:00:51 +01:00
|
|
|
const int kLevel = 0;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// percentage flexibilty while reducing size amplification
|
2014-10-02 01:19:16 +02:00
|
|
|
uint64_t ratio = ioptions_.compaction_options_universal.
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
max_size_amplification_percent;
|
|
|
|
|
|
|
|
// The files are sorted from newest first to oldest last.
|
2014-10-28 18:00:51 +01:00
|
|
|
const auto& files = version->LevelFiles(kLevel);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
unsigned int candidate_count = 0;
|
|
|
|
uint64_t candidate_size = 0;
|
|
|
|
unsigned int start_index = 0;
|
|
|
|
FileMetaData* f = nullptr;
|
|
|
|
|
|
|
|
// Skip files that are already being compacted
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int loop = 0; loop < files.size() - 1; loop++) {
|
|
|
|
f = files[loop];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (!f->being_compacted) {
|
|
|
|
start_index = loop; // Consider this as the first candidate.
|
|
|
|
break;
|
|
|
|
}
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(f->fd.GetNumber(), f->fd.GetPathId(), file_num_buf,
|
|
|
|
sizeof(file_num_buf));
|
2014-07-02 18:54:20 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: skipping file %s[%d] compacted %s",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), file_num_buf, loop,
|
2014-08-13 20:57:40 +02:00
|
|
|
" cannot be a candidate to reduce size amp.\n");
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
f = nullptr;
|
|
|
|
}
|
2014-10-28 18:00:51 +01:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (f == nullptr) {
|
|
|
|
return nullptr; // no candidate files
|
|
|
|
}
|
|
|
|
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(f->fd.GetNumber(), f->fd.GetPathId(), file_num_buf,
|
|
|
|
sizeof(file_num_buf));
|
2014-07-02 18:54:20 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] Universal: First candidate file %s[%d] %s",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), file_num_buf, start_index,
|
2014-08-13 20:57:40 +02:00
|
|
|
" to reduce size amp.\n");
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// keep adding up all the remaining files
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int loop = start_index; loop < files.size() - 1; loop++) {
|
|
|
|
f = files[loop];
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
if (f->being_compacted) {
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(f->fd.GetNumber(), f->fd.GetPathId(), file_num_buf,
|
|
|
|
sizeof(file_num_buf));
|
Buffer info logs when picking compactions and write them out after releasing the mutex
Summary: Now while the background thread is picking compactions, it writes out multiple info_logs, especially for universal compaction, which introduces a chance of waiting log writing in mutex, which is bad. To remove this risk, write all those info logs to a buffer and flush it after releasing the mutex.
Test Plan:
make all check
check the log lines while running some tests that trigger compactions.
Reviewers: haobo, igor, dhruba
Reviewed By: dhruba
CC: i.am.jin.lei, dhruba, yhchiang, leveldb, nkg-
Differential Revision: https://reviews.facebook.net/D16515
2014-03-04 23:32:55 +01:00
|
|
|
LogToBuffer(
|
2014-07-02 18:54:20 +02:00
|
|
|
log_buffer, "[%s] Universal: Possible candidate file %s[%d] %s.",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), file_num_buf, loop,
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
" is already being compacted. No size amp reduction possible.\n");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-06-25 00:37:06 +02:00
|
|
|
candidate_size += f->compensated_file_size;
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
candidate_count++;
|
|
|
|
}
|
|
|
|
if (candidate_count == 0) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// size of earliest file
|
2014-07-01 08:55:04 +02:00
|
|
|
uint64_t earliest_file_size = files.back()->fd.GetFileSize();
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
|
|
|
// size amplification = percentage of additional size
|
|
|
|
if (candidate_size * 100 < ratio * earliest_file_size) {
|
2014-04-25 15:51:16 +02:00
|
|
|
LogToBuffer(
|
|
|
|
log_buffer,
|
2014-06-28 01:01:59 +02:00
|
|
|
"[%s] Universal: size amp not needed. newer-files-total-size %" PRIu64
|
|
|
|
"earliest-file-size %" PRIu64,
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), candidate_size, earliest_file_size);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
return nullptr;
|
|
|
|
} else {
|
2014-06-28 01:01:59 +02:00
|
|
|
LogToBuffer(
|
|
|
|
log_buffer,
|
|
|
|
"[%s] Universal: size amp needed. newer-files-total-size %" PRIu64
|
|
|
|
"earliest-file-size %" PRIu64,
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), candidate_size, earliest_file_size);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
2014-09-29 23:31:47 +02:00
|
|
|
assert(start_index < files.size() - 1);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
|
2014-07-15 00:34:30 +02:00
|
|
|
// Estimate total file size
|
|
|
|
uint64_t estimated_total_size = 0;
|
|
|
|
for (unsigned int loop = start_index; loop < files.size(); loop++) {
|
|
|
|
estimated_total_size += files[loop]->fd.GetFileSize();
|
|
|
|
}
|
2014-10-02 01:19:16 +02:00
|
|
|
uint32_t path_id = GetPathId(ioptions_, estimated_total_size);
|
2014-07-15 00:34:30 +02:00
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
// create a compaction request
|
|
|
|
// We always compact all the files, so always compress.
|
|
|
|
Compaction* c =
|
2014-10-28 18:00:51 +01:00
|
|
|
new Compaction(version, kLevel, kLevel,
|
|
|
|
mutable_cf_options.MaxFileSizeForLevel(kLevel),
|
|
|
|
LLONG_MAX, path_id, GetCompressionType(ioptions_, kLevel));
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
c->score_ = score;
|
2014-07-01 08:55:04 +02:00
|
|
|
for (unsigned int loop = start_index; loop < files.size(); loop++) {
|
2014-10-28 18:00:51 +01:00
|
|
|
f = files[loop];
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files.push_back(f);
|
Buffer info logs when picking compactions and write them out after releasing the mutex
Summary: Now while the background thread is picking compactions, it writes out multiple info_logs, especially for universal compaction, which introduces a chance of waiting log writing in mutex, which is bad. To remove this risk, write all those info logs to a buffer and flush it after releasing the mutex.
Test Plan:
make all check
check the log lines while running some tests that trigger compactions.
Reviewers: haobo, igor, dhruba
Reviewed By: dhruba
CC: i.am.jin.lei, dhruba, yhchiang, leveldb, nkg-
Differential Revision: https://reviews.facebook.net/D16515
2014-03-04 23:32:55 +01:00
|
|
|
LogToBuffer(log_buffer,
|
2014-06-25 00:37:06 +02:00
|
|
|
"[%s] Universal: size amp picking file %" PRIu64 "[%d] "
|
|
|
|
"with size %" PRIu64 " (compensated size %" PRIu64 ")",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(),
|
2014-07-01 10:55:03 +02:00
|
|
|
f->fd.GetNumber(), loop,
|
2014-06-25 00:37:06 +02:00
|
|
|
f->fd.GetFileSize(), f->compensated_file_size);
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
Compaction* FIFOCompactionPicker::PickCompaction(
|
|
|
|
const MutableCFOptions& mutable_cf_options,
|
|
|
|
Version* version, LogBuffer* log_buffer) {
|
2014-05-21 20:43:35 +02:00
|
|
|
assert(version->NumberLevels() == 1);
|
2014-10-28 18:00:51 +01:00
|
|
|
const int kLevel0 = 0;
|
|
|
|
const std::vector<FileMetaData*>& level_files = version->LevelFiles(kLevel0);
|
2014-05-21 20:43:35 +02:00
|
|
|
uint64_t total_size = 0;
|
2014-10-28 18:00:51 +01:00
|
|
|
for (const auto& file : level_files) {
|
2014-06-25 00:37:06 +02:00
|
|
|
total_size += file->compensated_file_size;
|
2014-05-21 20:43:35 +02:00
|
|
|
}
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
if (total_size <= ioptions_.compaction_options_fifo.max_table_files_size ||
|
2014-10-28 18:00:51 +01:00
|
|
|
level_files.size() == 0) {
|
2014-05-21 20:43:35 +02:00
|
|
|
// total size not exceeded
|
|
|
|
LogToBuffer(log_buffer,
|
|
|
|
"[%s] FIFO compaction: nothing to do. Total size %" PRIu64
|
|
|
|
", max size %" PRIu64 "\n",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), total_size,
|
2014-10-02 01:19:16 +02:00
|
|
|
ioptions_.compaction_options_fifo.max_table_files_size);
|
2014-05-21 20:43:35 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compactions_in_progress_[0].size() > 0) {
|
|
|
|
LogToBuffer(log_buffer,
|
|
|
|
"[%s] FIFO compaction: Already executing compaction. No need "
|
|
|
|
"to run parallel compactions since compactions are very fast",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str());
|
2014-05-21 20:43:35 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 18:54:20 +02:00
|
|
|
Compaction* c = new Compaction(version, 0, 0, 0, 0, 0, kNoCompression, false,
|
2014-05-21 20:43:35 +02:00
|
|
|
true /* is deletion compaction */);
|
|
|
|
// delete old files (FIFO)
|
2014-10-28 18:00:51 +01:00
|
|
|
for (auto ritr = level_files.rbegin(); ritr != level_files.rend(); ++ritr) {
|
2014-05-21 20:43:35 +02:00
|
|
|
auto f = *ritr;
|
2014-06-25 00:37:06 +02:00
|
|
|
total_size -= f->compensated_file_size;
|
2014-07-17 03:12:17 +02:00
|
|
|
c->inputs_[0].files.push_back(f);
|
2014-05-21 20:43:35 +02:00
|
|
|
char tmp_fsize[16];
|
2014-06-14 00:54:19 +02:00
|
|
|
AppendHumanBytes(f->fd.GetFileSize(), tmp_fsize, sizeof(tmp_fsize));
|
2014-05-21 20:43:35 +02:00
|
|
|
LogToBuffer(log_buffer, "[%s] FIFO compaction: picking file %" PRIu64
|
|
|
|
" with size %s for deletion",
|
2014-10-28 18:00:51 +01:00
|
|
|
version->cfd()->GetName().c_str(), f->fd.GetNumber(),
|
|
|
|
tmp_fsize);
|
2014-10-02 01:19:16 +02:00
|
|
|
if (total_size <= ioptions_.compaction_options_fifo.max_table_files_size) {
|
2014-05-21 20:43:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c->MarkFilesBeingCompacted(true);
|
|
|
|
compactions_in_progress_[0].insert(c);
|
2014-10-02 01:19:16 +02:00
|
|
|
c->mutable_cf_options_ = mutable_cf_options;
|
2014-05-21 20:43:35 +02:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2014-07-17 02:39:18 +02:00
|
|
|
Compaction* FIFOCompactionPicker::CompactRange(
|
2014-10-02 01:19:16 +02:00
|
|
|
const MutableCFOptions& mutable_cf_options,
|
2014-07-17 02:39:18 +02:00
|
|
|
Version* version, int input_level, int output_level,
|
|
|
|
uint32_t output_path_id, const InternalKey* begin, const InternalKey* end,
|
|
|
|
InternalKey** compaction_end) {
|
2014-05-21 20:43:35 +02:00
|
|
|
assert(input_level == 0);
|
|
|
|
assert(output_level == 0);
|
|
|
|
*compaction_end = nullptr;
|
2014-10-02 01:19:16 +02:00
|
|
|
LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, ioptions_.info_log);
|
|
|
|
Compaction* c = PickCompaction(mutable_cf_options, version, &log_buffer);
|
2014-07-17 02:39:18 +02:00
|
|
|
if (c != nullptr) {
|
2014-10-02 01:19:16 +02:00
|
|
|
assert(output_path_id < static_cast<uint32_t>(ioptions_.db_paths.size()));
|
2014-07-17 02:39:18 +02:00
|
|
|
c->output_path_id_ = output_path_id;
|
|
|
|
}
|
2014-05-21 20:43:35 +02:00
|
|
|
log_buffer.FlushBufferToLog();
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
CompactionPicker
Summary:
This is a big one. This diff moves all the code related to picking compactions from VersionSet to new class CompactionPicker. Column families' compactions will be completely separate processes, so we need to have multiple CompactionPickers.
To make this easier to review, most of the code change is just copy/paste. There is also a small change not to use VersionSet::current_, but rather to take `Version* version` as a parameter. Most of the other code is exactly the same.
In future diffs, I will also make some improvements to CompactionPickers. I think the most important part will be encapsulating it better. Currently Version, VersionSet, Compaction and CompactionPicker are all friend classes, which makes it harder to change the implementation.
This diff depends on D15171, D15183, D15189 and D15201
Test Plan: `make check`
Reviewers: kailiu, sdong, dhruba, haobo
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15207
2014-01-16 22:03:52 +01:00
|
|
|
} // namespace rocksdb
|