0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

ircd::db: Custom table opts; table cache; introduce the bloom filter.

This commit is contained in:
Jason Volk 2018-04-14 23:00:56 -07:00
parent f0dc31d284
commit 0a3259afae
4 changed files with 54 additions and 3 deletions

View file

@ -38,6 +38,7 @@ struct ircd::db::database::column final
database::descriptor descriptor;
comparator cmp;
prefix_transform prefix;
rocksdb::BlockBasedTableOptions table_opts;
custom_ptr<rocksdb::ColumnFamilyHandle> handle;
public:

View file

@ -23,4 +23,7 @@ struct ircd::db::database::descriptor
std::string options {};
db::comparator cmp {};
db::prefix_transform prefix {};
size_t cache_size { 16_MiB };
size_t cache_size_comp { 8_MiB };
size_t bloom_bits { 10 };
};

View file

@ -21,6 +21,8 @@
#include <rocksdb/env.h>
#include <rocksdb/slice_transform.h>
#include <rocksdb/utilities/checkpoint.h>
#include <rocksdb/filter_policy.h>
#include <rocksdb/table.h>
#include <ircd/db/database/comparator.h>
#include <ircd/db/database/prefix_transform.h>
@ -305,8 +307,8 @@ try
,cache{[this]
() -> std::shared_ptr<rocksdb::Cache>
{
//TODO: XXX
const auto lru_cache_size{512_MiB};
//TODO: conf
const auto lru_cache_size{256_MiB};
return rocksdb::NewLRUCache(lru_cache_size);
}()}
,descriptors
@ -873,15 +875,33 @@ ircd::db::database::column::column(database *const &d,
//if(d->mergeop->merger)
// this->options.merge_operator = d->mergeop;
const auto &cache_size(this->descriptor.cache_size);
table_opts.block_cache = rocksdb::NewLRUCache(cache_size);
const auto &cache_size_comp(this->descriptor.cache_size_comp);
table_opts.block_cache_compressed = rocksdb::NewLRUCache(cache_size_comp);
// Tickers::READ_AMP_TOTAL_READ_BYTES / Tickers::READ_AMP_ESTIMATE_USEFUL_BYTES
//table_opts.read_amp_bytes_per_bit = 8;
const auto &bloom_bits(this->descriptor.bloom_bits);
if(bloom_bits)
table_opts.filter_policy.reset(rocksdb::NewBloomFilterPolicy(bloom_bits, false));
this->options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(table_opts));
//log.debug("'%s': Creating new column '%s'", d->name, this->name);
//throw_on_error(d->d->CreateColumnFamily(this->options, this->name, &this->handle));
log.debug("schema '%s' declares column [%s => %s] cmp[%s] prefix[%s]: %s",
log.debug("schema '%s' declares column [%s => %s] cmp[%s] pfx[%s] lru:%zu:%zu bloom:%zu %s",
db::name(*d),
demangle(key_type.name()),
demangle(mapped_type.name()),
this->cmp.Name(),
this->options.prefix_extractor? this->prefix.Name() : "none",
cache_size,
cache_size_comp,
bloom_bits,
this->descriptor.name);
}

View file

@ -444,6 +444,12 @@ ircd::m::dbs::desc::events__state_node
// prefix transform
{},
// cache size
96_MiB, //TODO: conf
// cache size for compressed assets
24_MiB, //TODO: conf
};
/// Prefix transform for the events__room_events. The prefix here is a room_id
@ -635,6 +641,15 @@ ircd::m::dbs::desc::events__room_events
// prefix transform
events__room_events__pfx,
// cache size
64_MiB, //TODO: conf
// cache size for compressed assets
24_MiB, //TODO: conf
// bloom filter bits
0, // no bloom filter because of possible comparator issues
};
//
@ -734,6 +749,12 @@ ircd::m::dbs::desc::events__room_origins
// prefix transform
events__room_origins__pfx,
// cache size
64_MiB, //TODO: conf
// cache size for compressed assets
16_MiB, //TODO: conf
};
//
@ -831,6 +852,12 @@ ircd::m::dbs::desc::events__room_state
// prefix transform
events__room_state__pfx,
// cache size
128_MiB, //TODO: conf
// cache size for compressed assets
32_MiB, //TODO: conf
};
//