pub struct Config { /* private fields */ }Expand description
The settings a database is opened with.
Three of them today: how much memory the engine may use, how many threads it may run a query on,
and how long a query may take. They are set once, at open time, and read back afterwards. That
is deliberately narrower than DuckDB, where almost anything can be changed by SET in the
middle of a session, and the narrower version is the one worth having first: a setting that can
change under a running query is a setting every operator has to re-read, and there is no
operator yet that would honour a change.
§What reads these, and what does not yet
--print-config prints them, and a harness that opened the database is the thing that told it
what to print, so the two agree by construction rather than by both being kept up to date. That
is the whole reason this exists now: a benchmark result that does not say how many threads it
used is not a result, and a run that says eight while the engine used one is worse than one that
says nothing.
The query timeout and the memory limit are enforced. The thread count is not yet, because that needs a parallel executor, which is E4, and the documentation on it says so rather than implying otherwise. Recording the intent first is what lets the harnesses be written against the final shape, and it is also what makes the gap visible: a setting that is stored and ignored is easier to find than a setting that was never accepted.
Implementations§
Source§impl Config
impl Config
Sourcepub fn memory_limit(&self) -> Option<u64>
pub fn memory_limit(&self) -> Option<u64>
How many bytes the engine may use, or None for no limit.
Enforced, by the operators that buffer without bound charging what they hold against one
budget for the whole database. A query that passes the limit stops with an Out of Memory Error saying what it asked for and what was already held. See rudb_common::Memory for
what is counted and what is not, which is a shorter list than it will be: nothing here hooks
the allocator, so the number is what the operators said they were holding.
The default is eighty percent of what the machine has, which is what DuckDB does, and None
on a platform that will not say how much that is. See rudb_io::machine for how each
platform is asked and why the answer on Linux is the smaller of the machine and the control
group.
It was None everywhere until #219, and the reason it is not any more is that a budget
nobody set is a budget the operating system enforces. Eight of the forty three ClickBench
queries ended in memory allocation of 128 bytes failed, which is the allocator’s abort
handler, so the process was gone and there was no error for a harness to report. The same
queries under a limit say Out of Memory Error and name what they asked for. A database
that has an out of memory error and does not use it unless asked is a database that aborts
on every machine where nobody typed the SET.
Config::with_no_memory_limit is still there and still means no limit, which is now a
thing somebody asks for rather than a thing they get.
Sourcepub fn threads(&self) -> usize
pub fn threads(&self) -> usize
How many threads a query may run on.
Defaults to the number of cores the program can see, which is what DuckDB does, and one if the operating system will not say. The executor is single threaded today, so this is recorded and not yet obeyed.
Sourcepub fn query_timeout(&self) -> Option<Duration>
pub fn query_timeout(&self) -> Option<Duration>
How long a query may run, or None for no limit.
Enforced. The clock starts when the statement starts, so it is a limit on one statement
rather than on a session, and a statement over the limit stops at its next chunk boundary
with an Interrupt Error saying what limit it passed. See crate::Cancel for what a
chunk boundary costs in response time and why it is the right place to check.
Sourcepub fn with_memory_limit(self, bytes: u64) -> Self
pub fn with_memory_limit(self, bytes: u64) -> Self
The same settings with this memory limit.
Sourcepub fn with_no_memory_limit(self) -> Self
pub fn with_no_memory_limit(self) -> Self
The same settings with no memory limit.
Sourcepub fn with_memory_limit_text(self, text: &str) -> Result<Self>
pub fn with_memory_limit_text(self, text: &str) -> Result<Self>
The same settings with this memory limit, written the way a person writes one.
1GB, 512MiB, 2048. See parse_size for exactly what is accepted and why the two
spellings of a gigabyte are two different numbers.
§Errors
When the text is not a size.
Sourcepub fn with_threads(self, threads: usize) -> Result<Self>
pub fn with_threads(self, threads: usize) -> Result<Self>
The same settings with this thread count.
§Errors
For zero, which would mean a query runs on nothing. DuckDB refuses it too.
Sourcepub fn with_query_timeout(self, timeout: Duration) -> Self
pub fn with_query_timeout(self, timeout: Duration) -> Self
The same settings with this query timeout.
Sourcepub fn with_no_query_timeout(self) -> Self
pub fn with_no_query_timeout(self) -> Self
The same settings with no query timeout.
Sourcepub fn settings(&self) -> Vec<(&'static str, String)>
pub fn settings(&self) -> Vec<(&'static str, String)>
Every setting as a name and a value, in a fixed order.
For --print-config and for a harness writing a run’s settings into its report. A list
rather than eight lines of formatting at each call site, so that a setting added here shows
up in both places without either of them being edited.