From 70575699e4ada1db41e2a189d69d0ec5591232a2 Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Mon, 4 Apr 2016 14:09:52 +0300 Subject: [PATCH] commitlog, sstables: enlarge XFS extent allocation for large files With big rows I see contention in XFS allocations which cause reactor thread to sleep. Commitlog is a main offender, so enlarge extent to commitlog segment size for big files (commitlog and sstable Data files). Message-Id: <20160404110952.GP20957@scylladb.com> --- db/commitlog/commitlog.cc | 4 +++- sstables/sstables.cc | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 91f09dbd8a..989365b69e 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -1060,7 +1060,9 @@ void db::commitlog::segment_manager::flush_segments(bool force) { future db::commitlog::segment_manager::allocate_segment(bool active) { descriptor d(next_id()); - return open_checked_file_dma(commit_error, cfg.commit_log_location + "/" + d.filename(), open_flags::wo | open_flags::create).then([this, d, active](file f) { + file_open_options opt; + opt.extent_allocation_size_hint = max_size; + return open_checked_file_dma(commit_error, cfg.commit_log_location + "/" + d.filename(), open_flags::wo | open_flags::create, opt).then([this, d, active](file f) { // xfs doesn't like files extended betond eof, so enlarge the file return f.truncate(max_size).then([this, d, active, f] () mutable { auto s = make_lw_shared(this->shared_from_this(), d, std::move(f), active); diff --git a/sstables/sstables.cc b/sstables/sstables.cc index e12361e82f..dd923dd9f8 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -65,6 +65,13 @@ future new_sstable_component_file(disk_error_signal_type& signal, sstring }); } +future new_sstable_component_file(disk_error_signal_type& signal, sstring name, open_flags flags, file_open_options options) { + return open_checked_file_dma(signal, name, flags, options).handle_exception([name] (auto ep) { + sstlog.error("Could not create SSTable component {}. Found exception: {}", name, ep); + return make_exception_future(ep); + }); +} + thread_local std::unordered_map> sstable::_shards_agreeing_to_remove_sstable; static utils::phased_barrier& background_jobs() { @@ -980,8 +987,10 @@ future<> sstable::open_data() { future<> sstable::create_data() { auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; + file_open_options opt; + opt.extent_allocation_size_hint = 32 << 20; return when_all(new_sstable_component_file(sstable_write_error, filename(component_type::Index), oflags), - new_sstable_component_file(sstable_write_error, filename(component_type::Data), oflags)).then([this] (auto files) { + new_sstable_component_file(sstable_write_error, filename(component_type::Data), oflags, opt)).then([this] (auto files) { // FIXME: If both files could not be created, the first get below will // throw an exception, and second get() will not be attempted, and // we'll get a warning about the second future being destructed