mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 16:34:13 +01:00
ircd::db: Custom table opts; table cache; introduce the bloom filter.
This commit is contained in:
parent
f0dc31d284
commit
0a3259afae
4 changed files with 54 additions and 3 deletions
|
@ -38,6 +38,7 @@ struct ircd::db::database::column final
|
||||||
database::descriptor descriptor;
|
database::descriptor descriptor;
|
||||||
comparator cmp;
|
comparator cmp;
|
||||||
prefix_transform prefix;
|
prefix_transform prefix;
|
||||||
|
rocksdb::BlockBasedTableOptions table_opts;
|
||||||
custom_ptr<rocksdb::ColumnFamilyHandle> handle;
|
custom_ptr<rocksdb::ColumnFamilyHandle> handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -23,4 +23,7 @@ struct ircd::db::database::descriptor
|
||||||
std::string options {};
|
std::string options {};
|
||||||
db::comparator cmp {};
|
db::comparator cmp {};
|
||||||
db::prefix_transform prefix {};
|
db::prefix_transform prefix {};
|
||||||
|
size_t cache_size { 16_MiB };
|
||||||
|
size_t cache_size_comp { 8_MiB };
|
||||||
|
size_t bloom_bits { 10 };
|
||||||
};
|
};
|
||||||
|
|
26
ircd/db.cc
26
ircd/db.cc
|
@ -21,6 +21,8 @@
|
||||||
#include <rocksdb/env.h>
|
#include <rocksdb/env.h>
|
||||||
#include <rocksdb/slice_transform.h>
|
#include <rocksdb/slice_transform.h>
|
||||||
#include <rocksdb/utilities/checkpoint.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/comparator.h>
|
||||||
#include <ircd/db/database/prefix_transform.h>
|
#include <ircd/db/database/prefix_transform.h>
|
||||||
|
@ -305,8 +307,8 @@ try
|
||||||
,cache{[this]
|
,cache{[this]
|
||||||
() -> std::shared_ptr<rocksdb::Cache>
|
() -> std::shared_ptr<rocksdb::Cache>
|
||||||
{
|
{
|
||||||
//TODO: XXX
|
//TODO: conf
|
||||||
const auto lru_cache_size{512_MiB};
|
const auto lru_cache_size{256_MiB};
|
||||||
return rocksdb::NewLRUCache(lru_cache_size);
|
return rocksdb::NewLRUCache(lru_cache_size);
|
||||||
}()}
|
}()}
|
||||||
,descriptors
|
,descriptors
|
||||||
|
@ -873,15 +875,33 @@ ircd::db::database::column::column(database *const &d,
|
||||||
//if(d->mergeop->merger)
|
//if(d->mergeop->merger)
|
||||||
// this->options.merge_operator = d->mergeop;
|
// 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);
|
//log.debug("'%s': Creating new column '%s'", d->name, this->name);
|
||||||
//throw_on_error(d->d->CreateColumnFamily(this->options, this->name, &this->handle));
|
//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),
|
db::name(*d),
|
||||||
demangle(key_type.name()),
|
demangle(key_type.name()),
|
||||||
demangle(mapped_type.name()),
|
demangle(mapped_type.name()),
|
||||||
this->cmp.Name(),
|
this->cmp.Name(),
|
||||||
this->options.prefix_extractor? this->prefix.Name() : "none",
|
this->options.prefix_extractor? this->prefix.Name() : "none",
|
||||||
|
cache_size,
|
||||||
|
cache_size_comp,
|
||||||
|
bloom_bits,
|
||||||
this->descriptor.name);
|
this->descriptor.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,12 @@ ircd::m::dbs::desc::events__state_node
|
||||||
|
|
||||||
// prefix transform
|
// 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
|
/// 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
|
// prefix transform
|
||||||
events__room_events__pfx,
|
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
|
// prefix transform
|
||||||
events__room_origins__pfx,
|
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
|
// prefix transform
|
||||||
events__room_state__pfx,
|
events__room_state__pfx,
|
||||||
|
|
||||||
|
// cache size
|
||||||
|
128_MiB, //TODO: conf
|
||||||
|
|
||||||
|
// cache size for compressed assets
|
||||||
|
32_MiB, //TODO: conf
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue