Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::Internal::RPagePool Class Reference

A thread-safe cache of pages loaded from the page source.

The page pool is used as a cache for pages loaded from a page source. In this way, identical page needed at the same time, only need to be loaded once. Page sources also use the page pool to stage (preload) pages unsealed by IMT tasks.

Definition at line 48 of file RPagePool.hxx.

Classes

struct  REntry
 Every page in the page pool is annotated with a search key and a reference counter. More...
 
struct  RKey
 
struct  RKeyHasher
 Hash function to be used in the unordered map fLookupByKey. More...
 
struct  RPagePosition
 Used in fLookupByKey to store both the absolute and the cluster-local page index of the referenced page. More...
 

Public Member Functions

 RPagePool ()=default
 
 RPagePool (const RPagePool &)=delete
 
 ~RPagePool ()=default
 
void Evict (DescriptorId_t clusterId)
 Removes unused pages (pages with reference counter 0) from the page pool.
 
RPageRef GetPage (RKey key, NTupleSize_t globalIndex)
 Tries to find the page corresponding to column and index in the cache.
 
RPageRef GetPage (RKey key, RClusterIndex clusterIndex)
 
RPagePooloperator= (const RPagePool &)=delete
 
void PreloadPage (RPage page, RKey key)
 Like RegisterPage() but the reference counter is initialized to 0.
 
RPageRef RegisterPage (RPage page, RKey key)
 Adds a new page to the pool.
 

Private Member Functions

REntryAddPage (RPage page, const RKey &key, std::int64_t initialRefCounter)
 Add a new page to the fLookupByBuffer and fLookupByKey data structures.
 
void ErasePage (std::size_t entryIdx, decltype(fLookupByBuffer)::iterator lookupByBufferItr)
 Called both by ReleasePage() and by Evict() to remove an unused page from the pool.
 
void ReleasePage (const RPage &page)
 Give back a page to the pool and decrease the reference counter.
 
void RemoveFromUnusedPages (const RPage &page)
 Called by GetPage(), when the reference counter increases from zero to one.
 

Private Attributes

std::vector< REntryfEntries
 All cached pages in the page pool.
 
std::mutex fLock
 The page pool is accessed concurrently due to parallel decompression.
 
std::unordered_map< void *, std::size_t > fLookupByBuffer
 Used in ReleasePage() to find the page index in fPages.
 
std::unordered_map< RKey, std::map< RPagePosition, std::size_t >, RKeyHasherfLookupByKey
 Used in GetPage() to find the right page in fEntries.
 
std::unordered_map< DescriptorId_t, std::unordered_set< void * > > fUnusedPages
 Remembers pages with reference counter 0, organized by the page's cluster id.
 

Friends

class RPageRef
 

#include <ROOT/RPagePool.hxx>

Constructor & Destructor Documentation

◆ RPagePool() [1/2]

ROOT::Experimental::Internal::RPagePool::RPagePool ( )
default

◆ RPagePool() [2/2]

ROOT::Experimental::Internal::RPagePool::RPagePool ( const RPagePool )
delete

◆ ~RPagePool()

ROOT::Experimental::Internal::RPagePool::~RPagePool ( )
default

Member Function Documentation

◆ AddPage()

ROOT::Experimental::Internal::RPagePool::REntry & ROOT::Experimental::Internal::RPagePool::AddPage ( RPage  page,
const RKey key,
std::int64_t  initialRefCounter 
)
private

Add a new page to the fLookupByBuffer and fLookupByKey data structures.

Definition at line 26 of file RPagePool.cxx.

◆ ErasePage()

void ROOT::Experimental::Internal::RPagePool::ErasePage ( std::size_t  entryIdx,
decltype(fLookupByBuffer)::iterator  lookupByBufferItr 
)
private

Called both by ReleasePage() and by Evict() to remove an unused page from the pool.

Definition at line 65 of file RPagePool.cxx.

◆ Evict()

void ROOT::Experimental::Internal::RPagePool::Evict ( DescriptorId_t  clusterId)

Removes unused pages (pages with reference counter 0) from the page pool.

Users of PreloadPage() should use Evict() appropriately to avoid accumulation of unused pages.

Definition at line 161 of file RPagePool.cxx.

◆ GetPage() [1/2]

ROOT::Experimental::Internal::RPageRef ROOT::Experimental::Internal::RPagePool::GetPage ( RKey  key,
NTupleSize_t  globalIndex 
)

Tries to find the page corresponding to column and index in the cache.

If the page is found, its reference counter is increased

Definition at line 116 of file RPagePool.cxx.

◆ GetPage() [2/2]

ROOT::Experimental::Internal::RPageRef ROOT::Experimental::Internal::RPagePool::GetPage ( RKey  key,
RClusterIndex  clusterIndex 
)

Definition at line 139 of file RPagePool.cxx.

◆ operator=()

RPagePool & ROOT::Experimental::Internal::RPagePool::operator= ( const RPagePool )
delete

◆ PreloadPage()

void ROOT::Experimental::Internal::RPagePool::PreloadPage ( RPage  page,
RKey  key 
)

Like RegisterPage() but the reference counter is initialized to 0.

In addition, the page is added to the set of unused pages of the page's cluster (see Evict()).

Definition at line 57 of file RPagePool.cxx.

◆ RegisterPage()

ROOT::Experimental::Internal::RPageRef ROOT::Experimental::Internal::RPagePool::RegisterPage ( RPage  page,
RKey  key 
)

Adds a new page to the pool.

Upon registration, the page pool takes ownership of the page's memory. The new page has its reference counter set to 1.

Definition at line 51 of file RPagePool.cxx.

◆ ReleasePage()

void ROOT::Experimental::Internal::RPagePool::ReleasePage ( const RPage page)
private

Give back a page to the pool and decrease the reference counter.

There must not be any pointers anymore into this page. If the reference counter drops to zero, the page pool might decide to call the deleter given in during registration. Called by the RPageRef destructor.

Definition at line 91 of file RPagePool.cxx.

◆ RemoveFromUnusedPages()

void ROOT::Experimental::Internal::RPagePool::RemoveFromUnusedPages ( const RPage page)
private

Called by GetPage(), when the reference counter increases from zero to one.

Definition at line 106 of file RPagePool.cxx.

Friends And Related Symbol Documentation

◆ RPageRef

friend class RPageRef
friend

Definition at line 49 of file RPagePool.hxx.

Member Data Documentation

◆ fEntries

std::vector<REntry> ROOT::Experimental::Internal::RPagePool::fEntries
private

All cached pages in the page pool.

Definition at line 117 of file RPagePool.hxx.

◆ fLock

std::mutex ROOT::Experimental::Internal::RPagePool::fLock
private

The page pool is accessed concurrently due to parallel decompression.

Definition at line 130 of file RPagePool.hxx.

◆ fLookupByBuffer

std::unordered_map<void *, std::size_t> ROOT::Experimental::Internal::RPagePool::fLookupByBuffer
private

Used in ReleasePage() to find the page index in fPages.

Definition at line 119 of file RPagePool.hxx.

◆ fLookupByKey

std::unordered_map<RKey, std::map<RPagePosition, std::size_t>, RKeyHasher> ROOT::Experimental::Internal::RPagePool::fLookupByKey
private

Used in GetPage() to find the right page in fEntries.

Lookup for the key (pair of on-disk and in-memory type) takes place in O(1). The selected pages are identified by index into the fEntries vector (map's value) and sorted by the position of the page in the column (map's key). Thus, access to pages of the page set has logarithmic complexity.

Definition at line 124 of file RPagePool.hxx.

◆ fUnusedPages

std::unordered_map<DescriptorId_t, std::unordered_set<void *> > ROOT::Experimental::Internal::RPagePool::fUnusedPages
private

Remembers pages with reference counter 0, organized by the page's cluster id.

The pages are identified by their page buffer address. The fLookupByBuffer map can be used to resolve the address to a page. Once a page gets used, it is removed from the unused pages list. Evict will remove all unused pages from a given cluster id.

Definition at line 129 of file RPagePool.hxx.

Libraries for ROOT::Experimental::Internal::RPagePool:

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