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) |
RPagePool & | operator= (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 | |
REntry & | AddPage (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< REntry > | fEntries |
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 >, RKeyHasher > | fLookupByKey |
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>
|
default |
|
delete |
|
default |
|
private |
Add a new page to the fLookupByBuffer and fLookupByKey data structures.
Definition at line 26 of file RPagePool.cxx.
|
private |
Called both by ReleasePage() and by Evict() to remove an unused page from the pool.
Definition at line 65 of file RPagePool.cxx.
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.
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.
ROOT::Experimental::Internal::RPageRef ROOT::Experimental::Internal::RPagePool::GetPage | ( | RKey | key, |
RClusterIndex | clusterIndex | ||
) |
Definition at line 139 of file RPagePool.cxx.
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.
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.
|
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.
|
private |
Called by GetPage(), when the reference counter increases from zero to one.
Definition at line 106 of file RPagePool.cxx.
|
friend |
Definition at line 49 of file RPagePool.hxx.
|
private |
All cached pages in the page pool.
Definition at line 117 of file RPagePool.hxx.
|
private |
The page pool is accessed concurrently due to parallel decompression.
Definition at line 130 of file RPagePool.hxx.
|
private |
Used in ReleasePage() to find the page index in fPages.
Definition at line 119 of file RPagePool.hxx.
|
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.
|
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.