35 const auto entryIndex =
fEntries.size();
39 auto [itrEntryIdx, isNew] = itrPageSet->second.emplace(
RPagePosition(page), entryIndex);
41 assert(itrEntryIdx->second <
fEntries.size());
44 fEntries[itrEntryIdx->second].fRefCounter += initialRefCounter;
45 return fEntries[itrEntryIdx->second];
54 return fEntries.emplace_back(
REntry{std::move(page), key, initialRefCounter});
59 std::lock_guard<std::mutex> lockGuard(
fLock);
65 std::lock_guard<std::mutex> lockGuard(
fLock);
66 const auto &entry =
AddPage(std::move(page), key, 0);
67 if (entry.fRefCounter == 0)
78 if (itrPageSet->second.empty())
83 if (entryIdx != (
N - 1)) {
88 assert(itrEntryIdx != itrPageSet->second.end());
89 itrEntryIdx->second = entryIdx;
100 std::lock_guard<std::mutex> lockGuard(
fLock);
104 const auto idx = itrLookup->second;
106 assert(
fEntries[idx].fRefCounter >= 1);
107 if (--
fEntries[idx].fRefCounter == 0) {
126 if (itr->second.empty())
132 std::lock_guard<std::mutex> lockGuard(
fLock);
136 assert(!itrPageSet->second.empty());
138 auto itrEntryIdx = itrPageSet->second.upper_bound(
RPagePosition(globalIndex));
139 if (itrEntryIdx == itrPageSet->second.begin())
143 if (
fEntries[itrEntryIdx->second].fPage.Contains(globalIndex)) {
144 if (
fEntries[itrEntryIdx->second].fRefCounter == 0)
146 fEntries[itrEntryIdx->second].fRefCounter++;
154 std::lock_guard<std::mutex> lockGuard(
fLock);
158 assert(!itrPageSet->second.empty());
160 auto itrEntryIdx = itrPageSet->second.upper_bound(
RPagePosition(localIndex));
161 if (itrEntryIdx == itrPageSet->second.begin())
165 if (
fEntries[itrEntryIdx->second].fPage.Contains(localIndex)) {
166 if (
fEntries[itrEntryIdx->second].fRefCounter == 0)
168 fEntries[itrEntryIdx->second].fRefCounter++;
176 std::lock_guard<std::mutex> lockGuard(
fLock);
181 for (
auto pageBuffer : itr->second) {
184 const auto entryIdx = itrLookupByBuffer->second;
185 assert(
fEntries[entryIdx].fRefCounter == 0);
A thread-safe integral performance counter.
A thread-safe integral performance counter.
std::unique_ptr< RCounters > fCounters
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.
ROOT::Experimental::Detail::RNTupleMetrics fMetrics
The page pool counters are observed by the page source.
void Evict(ROOT::DescriptorId_t clusterId)
Removes unused pages (pages with reference counter 0) from the page pool.
REntry & AddPage(RPage page, const RKey &key, std::int64_t initialRefCounter)
Add a new page to the fLookupByBuffer and fLookupByKey data structures.
std::unordered_map< ROOT::DescriptorId_t, std::unordered_set< void * > > fUnusedPages
Remembers pages with reference counter 0, organized by the page's cluster id.
std::mutex fLock
The page pool is accessed concurrently due to parallel decompression.
RPageRef GetPage(RKey key, ROOT::NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
RPagePool(RPageSource &pageSource)
std::unordered_map< RKey, std::map< RPagePosition, std::size_t >, RKeyHasher > fLookupByKey
Used in GetPage() to find the right page in fEntries.
void AddToUnusedPages(const RPage &page)
Called by PreloadPage() if the page at hand is new and thus added with ref counter 0.
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.
void RemoveFromUnusedPages(const RPage &page)
Called by GetPage(), when the reference counter increases from zero to one.
RPageSource & fPageSource
Every page pool is associated to exactly one page source.
std::unordered_map< void *, std::size_t > fLookupByBuffer
Used in ReleasePage() to find the page index in fPages.
std::vector< REntry > fEntries
All cached pages in the page pool.
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
Abstract interface to read data from an ntuple.
ROOT::DescriptorId_t GetId() const
A page is a slice of a column that is mapped into memory.
ROOT::NTupleSize_t GetGlobalRangeLast() const
const RClusterInfo & GetClusterInfo() const
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Performance counters that get registered in fMetrics.
Every page in the page pool is annotated with a search key and a reference counter.
Used in fLookupByKey to store both the absolute and the cluster-local page index of the referenced pa...