db: make compaction slightly faster by not using filtering reader on unshared sstable

After reboot, all existing sstables are considered shared. That's a safe default.
Reader used by compaction decides to use filtering reader (filters out data that
doesn't belong to this shard) if sstable is considered shared even though it may
actually be unshared.
By avoiding filtering reader we're avoiding an extra check for each key, and that
may be meaningful for compaction of tons of small partitions and even range
reads of such. We do so by fixing sstable::_shared, which is now set properly for
existing sstables at start.

quick check using microbenchmark which extends perf_sstable with compaction mode:
before: 69407.61 +- 37.03 partitions / sec (30 runs, 1 concurrent ops)
after: 70161.09 +- 40.35 partitions / sec (30 runs, 1 concurrent ops)

Fixes #3042.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20180504182158.21130-1-raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2018-05-04 15:21:58 -03:00
committed by Duarte Nunes
parent b65bc511fe
commit abcfc19fe9

View File

@@ -761,6 +761,9 @@ column_family::open_sstable(sstables::foreign_sstable_open_info info, sstring di
dblog.debug("sstable {} not relevant for this shard, ignoring", sst->get_filename());
return make_ready_future<sstables::shared_sstable>();
}
if (!belongs_to_other_shard(info.owners)) {
sst->set_unshared();
}
return sst->load(std::move(info)).then([sst] () mutable {
return make_ready_future<sstables::shared_sstable>(std::move(sst));
});