Skip to main content

PagePool

Struct PagePool 

Source
pub struct PagePool { /* private fields */ }
Expand description

The pages every reader of one database keeps, under one budget in bytes.

A reader lives as long as the database does, so the pages it holds are what the next query finds already in memory. They used to be four stripes a column, oldest out first, which on TPC-H SF1 meant every query read every page of lineitem off the file again and paid the system call for it. Keeping every page there costs 38 MB and took a third of the system time off the suite.

So the question is no longer how many stripes a column keeps but how many bytes the database does, and one budget answers it for every reader at once. A table nobody queries gives its pages up to one that is being queried, which a count per column cannot do.

Pages leave by the clock. Each has a bit a read sets, and when the pool is over budget it walks from the oldest: a page with the bit set loses the bit and goes round again, and a page without it goes. That keeps what is read over and over and lets a page one scan read once go first.

The old count is still a floor. A column never gives up a page while it holds four or fewer, because a scan whose workers evict each other’s pages reads a quarter of a megabyte for every part it takes, and a budget of zero is the cache as it was before the pool existed.

Implementations§

Source§

impl PagePool

Source

pub fn new(budget: usize) -> Self

A pool that keeps up to budget bytes of pages beyond each column’s floor.

Source

pub fn bytes(&self) -> usize

The bytes of pages the pool is counting now.

§Panics

If the pool’s lock is poisoned, which takes a panic while it was held.

Trait Implementations§

Source§

impl Clone for PagePool

Source§

fn clone(&self) -> Self

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 Debug for PagePool

Source§

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

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

impl Default for PagePool

Source§

fn default() -> Self

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

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.