configurable gc threshold

This commit is contained in:
2024-01-04 11:42:39 +01:00
parent 9a7745c9e2
commit 609794ebf2
3 changed files with 5 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ private:
const static inline std::unordered_map<std::string, std::variant<size_t, bool>> _defaults{{"cell_limit", 50000U},
{"command_strs", false},
{"default_log_level", 1U},
{"gc_threshold", 50U},
{"repl", true}};
std::unordered_map<std::string, std::variant<size_t, bool>> _current = _defaults;

View File

@@ -95,7 +95,8 @@ private:
std::lock_guard tmplg(_new_roots_lock);
Handle ret(cell);
_temp_cells.emplace_back(cell);
if ((_cells_num + _temp_cells.size() + 1) >= (size_t) (Options::get<size_t>("cell_limit") / 2)) {
if ((_cells_num + _temp_cells.size()) >=
((Options::get<size_t>("cell_limit") * Options::get<size_t>("gc_threshold")) / 100ULL)) {
request_gc();
}
return ret;

View File

@@ -300,6 +300,7 @@ void VM::step() {
std::string read;
std::getline(_instream, read);
_s.push(Parser::parse_str(read));
break;
}
default:
throw std::invalid_argument("Unknown command: " + std::to_string(poppedCmd));