mirror of
https://github.com/matrix-construct/construct
synced 2025-01-20 19:41:55 +01:00
ircd::db: Optimize make_opts w/ pre-construction and assumptions for noexcept copy.
This commit is contained in:
parent
d48e6ccb8d
commit
36b85a5c78
2 changed files with 21 additions and 15 deletions
32
ircd/db.cc
32
ircd/db.cc
|
@ -3784,7 +3784,8 @@ ircd::db::seek(column::const_iterator_base &it,
|
|||
const pos &p)
|
||||
{
|
||||
database::column &c(it);
|
||||
return seek(c, p, make_opts(it.opts), it.it);
|
||||
const auto opts(make_opts(it.opts));
|
||||
return seek(c, p, opts, it.it);
|
||||
}
|
||||
template bool ircd::db::seek<ircd::db::pos>(column::const_iterator_base &, const pos &);
|
||||
template bool ircd::db::seek<ircd::string_view>(column::const_iterator_base &, const string_view &);
|
||||
|
@ -4877,7 +4878,8 @@ ircd::db::seek(column &column,
|
|||
database::column &c(column);
|
||||
|
||||
std::unique_ptr<rocksdb::Iterator> ret;
|
||||
seek(c, key, make_opts(opts), ret);
|
||||
const auto ropts(make_opts(opts));
|
||||
seek(c, key, ropts, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -5317,19 +5319,22 @@ namespace ircd::db
|
|||
[[gnu::hot]]
|
||||
rocksdb::ReadOptions
|
||||
ircd::db::make_opts(const gopts &opts)
|
||||
noexcept
|
||||
{
|
||||
rocksdb::ReadOptions ret;
|
||||
assume(ret.iterate_lower_bound == nullptr);
|
||||
assume(ret.iterate_upper_bound == nullptr);
|
||||
assume(ret.pin_data == false);
|
||||
assume(ret.fill_cache == true);
|
||||
assume(ret.total_order_seek == false);
|
||||
assume(ret.verify_checksums == true);
|
||||
assume(ret.tailing == false);
|
||||
assume(ret.read_tier == rocksdb::ReadTier::kReadAllTier);
|
||||
assume(ret.readahead_size == 0);
|
||||
assume(ret.prefix_same_as_start == false);
|
||||
const auto &def{default_read_options};
|
||||
assume(def.iterate_lower_bound == nullptr);
|
||||
assume(def.iterate_upper_bound == nullptr);
|
||||
assume(def.pin_data == false);
|
||||
assume(def.fill_cache == true);
|
||||
assume(def.total_order_seek == false);
|
||||
assume(def.verify_checksums == true);
|
||||
assume(def.tailing == false);
|
||||
assume(def.read_tier == rocksdb::ReadTier::kReadAllTier);
|
||||
assume(def.readahead_size == 0);
|
||||
assume(def.prefix_same_as_start == false);
|
||||
assume(def.table_filter == nullptr);
|
||||
|
||||
rocksdb::ReadOptions ret{def};
|
||||
ret.snapshot = opts.snapshot;
|
||||
ret.readahead_size = opts.readahead;
|
||||
|
||||
|
@ -5374,6 +5379,7 @@ ircd::db::enable_wal
|
|||
[[gnu::hot]]
|
||||
rocksdb::WriteOptions
|
||||
ircd::db::make_opts(const sopts &opts)
|
||||
noexcept
|
||||
{
|
||||
rocksdb::WriteOptions ret;
|
||||
ret.sync = opts.fsync;
|
||||
|
|
|
@ -97,8 +97,8 @@ namespace ircd::db
|
|||
const std::string &reflect(const rocksdb::Histograms &);
|
||||
|
||||
// Frequently used get options and set options are separate from the string/map system
|
||||
rocksdb::WriteOptions make_opts(const sopts &);
|
||||
rocksdb::ReadOptions make_opts(const gopts &);
|
||||
rocksdb::WriteOptions make_opts(const sopts &) noexcept;
|
||||
rocksdb::ReadOptions make_opts(const gopts &) noexcept;
|
||||
|
||||
// Database options creator
|
||||
static bool optstr_find_and_remove(std::string &optstr, const std::string &what);
|
||||
|
|
Loading…
Add table
Reference in a new issue