Skip to main content

Config

Struct Config 

Source
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

Source

pub fn new() -> Self

The defaults.

Source

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.

Source

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.

Source

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.

Source

pub fn with_memory_limit(self, bytes: u64) -> Self

The same settings with this memory limit.

Source

pub fn with_no_memory_limit(self) -> Self

The same settings with no memory limit.

Source

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.

Source

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.

Source

pub fn with_query_timeout(self, timeout: Duration) -> Self

The same settings with this query timeout.

Source

pub fn with_no_query_timeout(self) -> Self

The same settings with no query timeout.

Source

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.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Config

Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Config

Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.