Files
scylladb/utils/memory_data_sink.hh
Paweł Dziepak 82a36edc9d Merge "Optimize sstable writing of the MC format" from Tomasz
"
Tested with perf_fast_forward from:

  github.com/tgrabiec/scylla.git perf_fast_forward-for-sst3-opt-write-v1

Using the following command line:

  build/release/tests/perf/perf_fast_forward_g --populate --sstable-format=mc \
     --data-directory /tmp/perf-mc --rows=10000000 -c1 -m4G \
     --datasets small-part

The average reported flush throughput was (stdev for the avergages is around 4k):
  - for mc before the series: 367848 frag/s
  - for lc before the series: 463458 frag/s (= mc.before +25%)
  - for mc after the series: 429276 frag/s (= mc.before +16%)
  - for lc after the series: 466495 frag/s (= mc.before +26%)

Refs #3874.
"

* tag 'sst3-opt-write-v2' of github.com:tgrabiec/scylla:
  sstables: mc: Avoid serialization of promoted index when empty
  sstables: mc: Avoid double serialization of rows
  tests: sstable 3.x: Do not compare Statistics component
  utils: Introduce memory_data_sink
  schema: Optimize column count getters
  sstables: checksummed_file_data_sink_impl: Bypass output_stream

(cherry picked from commit 4aa5d83590)
2018-11-24 12:36:40 +02:00

69 lines
1.9 KiB
C++

/*
* Copyright (C) 2018 ScyllaDB
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#include <seastar/core/iostream.hh>
#include "utils/small_vector.hh"
#pragma once
// Accumulates data sent to the memory_data_sink allowing it
// to be examined later.
class memory_data_sink_buffers {
using buffers_type = utils::small_vector<temporary_buffer<char>, 1>;
buffers_type _bufs;
size_t _size = 0;
public:
size_t size() const { return _size; }
buffers_type& buffers() { return _bufs; }
// Strong exception guarantees
void put(temporary_buffer<char>&& buf) {
auto size = buf.size();
_bufs.emplace_back(std::move(buf));
_size += size;
}
void clear() {
_bufs.clear();
_size = 0;
}
};
class memory_data_sink : public data_sink_impl {
memory_data_sink_buffers& _bufs;
public:
memory_data_sink(memory_data_sink_buffers& b) : _bufs(b) {}
virtual future<> put(net::packet data) override {
abort();
return make_ready_future<>();
}
virtual future<> put(temporary_buffer<char> buf) override {
_bufs.put(std::move(buf));
return make_ready_future<>();
}
virtual future<> flush() override {
return make_ready_future<>();
}
virtual future<> close() override {
return make_ready_future<>();
}
};