Configure authorized_prepared_statment_cache memory limit during object creation

This commit is contained in:
Gleb Natapov
2018-06-06 15:34:28 +03:00
committed by Avi Kivity
parent b38ced0fcd
commit da20d86423
5 changed files with 7 additions and 6 deletions

View File

@@ -110,8 +110,8 @@ private:
public:
// Choose the memory budget such that would allow us ~4K entries when a shard gets 1GB of RAM
authorized_prepared_statements_cache(std::chrono::milliseconds entry_expiration, std::chrono::milliseconds entry_refresh, logging::logger& logger)
: _cache(memory::stats().total_memory() / 2560, entry_expiration, entry_refresh, logger, [this] (const key_type& k) {
authorized_prepared_statements_cache(std::chrono::milliseconds entry_expiration, std::chrono::milliseconds entry_refresh, size_t cache_size, logging::logger& logger)
: _cache(cache_size, entry_expiration, entry_refresh, logger, [this] (const key_type& k) {
_cache.remove(k);
return make_ready_future<value_type>();
})
@@ -184,4 +184,4 @@ struct hash<cql3::authorized_prepared_statements_cache_key> final {
inline std::ostream& operator<<(std::ostream& out, const cql3::authorized_prepared_statements_cache_key& k) {
return out << "{ " << k.key().first << ", " << k.key().second << " }";
}
}
}

View File

@@ -101,7 +101,7 @@ query_processor::query_processor(service::storage_proxy& proxy, distributed<data
, _authorized_prepared_cache(std::min(std::chrono::milliseconds(_db.local().get_config().permissions_validity_in_ms()),
std::chrono::duration_cast<std::chrono::milliseconds>(prepared_statements_cache::entry_expiry)),
std::chrono::milliseconds(_db.local().get_config().permissions_update_interval_in_ms()),
authorized_prepared_statements_cache_log) {
mcfg.authorized_prepared_cache_size, authorized_prepared_statements_cache_log) {
namespace sm = seastar::metrics;
_metrics.add_group(

View File

@@ -102,6 +102,7 @@ public:
class migration_subscriber;
struct memory_config {
size_t prepared_statment_cache_size = 0;
size_t authorized_prepared_cache_size = 0;
};
private:

View File

@@ -603,7 +603,7 @@ int main(int ac, char** av) {
// #293 - do not stop anything
// engine().at_exit([&mm] { return mm.stop(); });
supervisor::notify("starting query processor");
cql3::query_processor::memory_config qp_mcfg = {memory::stats().total_memory() / 256};
cql3::query_processor::memory_config qp_mcfg = {memory::stats().total_memory() / 256, memory::stats().total_memory() / 2560};
qp.start(std::ref(proxy), std::ref(db), qp_mcfg).get();
// #293 - do not stop anything
// engine().at_exit([&qp] { return qp.stop(); });

View File

@@ -361,7 +361,7 @@ public:
auto stop_mm = defer([&mm] { mm.stop().get(); });
auto& qp = cql3::get_query_processor();
cql3::query_processor::memory_config qp_mcfg = {memory::stats().total_memory() / 256};
cql3::query_processor::memory_config qp_mcfg = {memory::stats().total_memory() / 256, memory::stats().total_memory() / 2560};
qp.start(std::ref(proxy), std::ref(*db), qp_mcfg).get();
auto stop_qp = defer([&qp] { qp.stop().get(); });