Zero  0.1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
alloc_cache_t Class Reference

Free-Page allocation/deallocation interface. More...

#include <alloc_cache.h>

Public Member Functions

 alloc_cache_t (stnode_cache_t &stcache, bool virgin, bool clustered)
 
rc_t sx_allocate_page (PageID &pid, StoreID stid=0)
 
rc_t sx_deallocate_page (PageID pid)
 
rc_t sx_format_alloc_page (PageID alloc_pid)
 
bool is_allocated (PageID pid)
 
PageID get_last_allocated_pid (StoreID s) const
 Returns last allocated PID of a given store. More...
 
PageID get_last_allocated_pid () const
 Returns last allocated PID of ALL stores. More...
 
PageID _get_last_allocated_pid_internal () const
 
lsn_t get_page_lsn (PageID pid)
 

Static Public Member Functions

static bool is_alloc_pid (PageID pid)
 

Static Public Attributes

static constexpr size_t extent_size = alloc_page::bits_held
 

Private Member Functions

rc_t load_alloc_page (StoreID stid, extent_id_t ext)
 

Private Attributes

std::vector< PageIDlast_alloc_page
 
stnode_cache_tstcache
 
srwlock_t _latch
 

Detailed Description

Free-Page allocation/deallocation interface.

This object handles allocation/deallocation requests for one volume. All allocation/deallocation are logged and done in a critical section. To make it scalable, this object is designed to be as fast as possible.

See also
alloc_page_h

Constructor & Destructor Documentation

§ alloc_cache_t()

alloc_cache_t::alloc_cache_t ( stnode_cache_t stcache,
bool  virgin,
bool  clustered 
)

Member Function Documentation

§ _get_last_allocated_pid_internal()

PageID alloc_cache_t::_get_last_allocated_pid_internal ( ) const

§ get_last_allocated_pid() [1/2]

PageID alloc_cache_t::get_last_allocated_pid ( StoreID  s) const

Returns last allocated PID of a given store.

§ get_last_allocated_pid() [2/2]

PageID alloc_cache_t::get_last_allocated_pid ( ) const

Returns last allocated PID of ALL stores.

§ get_page_lsn()

lsn_t alloc_cache_t::get_page_lsn ( PageID  pid)

§ is_alloc_pid()

static bool alloc_cache_t::is_alloc_pid ( PageID  pid)
inlinestatic

§ is_allocated()

bool alloc_cache_t::is_allocated ( PageID  pid)

§ load_alloc_page()

rc_t alloc_cache_t::load_alloc_page ( StoreID  stid,
extent_id_t  ext 
)
private

Reads the alloc page of given extent to update last_alloc_page

§ sx_allocate_page()

rc_t alloc_cache_t::sx_allocate_page ( PageID pid,
StoreID  stid = 0 
)

Allocates one page. (System transaction)

Parameters
[out]pidallocated page ID.
[in]stidStoreID to which this page will belong – this is used for clustering pages of the same store in the same extents

§ sx_deallocate_page()

rc_t alloc_cache_t::sx_deallocate_page ( PageID  pid)

Deallocates one page. (System transaction)

Parameters
[in]pidpage ID to deallocate.

§ sx_format_alloc_page()

rc_t alloc_cache_t::sx_format_alloc_page ( PageID  alloc_pid)

Formats an alloc page for a new extent. Called internally in sx_allocate_page.

Member Data Documentation

§ _latch

srwlock_t alloc_cache_t::_latch
mutableprivate

This lath protects access to last_alloc_page

§ extent_size

constexpr size_t alloc_cache_t::extent_size = alloc_page::bits_held
static

§ last_alloc_page

std::vector<PageID> alloc_cache_t::last_alloc_page
private

Keep track of free pages using the ID of the last allocated page and a list of free pages whose IDs are lower than that.

Pages which are freed end up in the list of freed pages, again one for each store. Currently, these lists are only used to determine whether a certain page is allocated or not. To avoid fragmentation in a workload with many deletions, items should be removed from these lists when allocating a page to avoid fragmentation. One extreme policy would be to only use the contiguous space when the corresponding list is empty, i.e., when the non-contiguous space has been fully utilized. Policies that trade off allocation performance for fragmentation by managing allocations from both contiguous and non-contiguous space would be the more flexible and robust option.

In Feb 2017, this was extended to support clustering pages by store ID, which requires assigning extents to stores exclusively, which means that we must keep track of page allocation on a per-store basis.

§ stcache

stnode_cache_t& alloc_cache_t::stcache
private

The documentation for this class was generated from the following files: