| 3157 | } |
| 3158 | |
| 3159 | Future<Reference<ArenaPage>> readMultiPage(PagerEventReasons reason, |
| 3160 | unsigned int level, |
| 3161 | VectorRef<PhysicalPageID> pageIDs, |
| 3162 | int priority, |
| 3163 | bool cacheable, |
| 3164 | bool noHit) override { |
| 3165 | // Use cached page if present, without triggering a cache hit. |
| 3166 | // Otherwise, read the page and return it but don't add it to the cache |
| 3167 | debug_printf("DWALPager(%s) op=read %s reason=%s noHit=%d\n", |
| 3168 | filename.c_str(), |
| 3169 | toString(pageIDs).c_str(), |
| 3170 | PagerEventReasonsStrings[(int)reason], |
| 3171 | noHit); |
| 3172 | auto& eventReasons = g_redwoodMetrics.level(level).metrics.events; |
| 3173 | eventReasons.addEventReason(PagerEvents::CacheLookup, reason); |
| 3174 | if (!cacheable) { |
| 3175 | debug_printf("DWALPager(%s) op=readUncached %s\n", filename.c_str(), toString(pageIDs).c_str()); |
| 3176 | PageCacheEntry* pCacheEntry = pageCache.getIfExists(pageIDs.front()); |
| 3177 | if (pCacheEntry != nullptr) { |
| 3178 | ++g_redwoodMetrics.metric.pagerProbeHit; |
| 3179 | debug_printf("DWALPager(%s) op=readUncachedHit %s\n", filename.c_str(), toString(pageIDs).c_str()); |
| 3180 | return pCacheEntry->readFuture; |
| 3181 | } |
| 3182 | ++g_redwoodMetrics.metric.pagerProbeMiss; |
| 3183 | debug_printf("DWALPager(%s) op=readUncachedMiss %s\n", filename.c_str(), toString(pageIDs).c_str()); |
| 3184 | return forwardError(readPhysicalMultiPage(this, pageIDs, priority), errorPromise); |
| 3185 | } |
| 3186 | |
| 3187 | PageCacheEntry& cacheEntry = pageCache.get(pageIDs.front(), pageIDs.size() * physicalPageSize, noHit); |
| 3188 | debug_printf("DWALPager(%s) op=read %s cached=%d reading=%d writing=%d noHit=%d\n", |
| 3189 | filename.c_str(), |
| 3190 | toString(pageIDs).c_str(), |
| 3191 | cacheEntry.initialized(), |
| 3192 | cacheEntry.initialized() && cacheEntry.reading(), |
| 3193 | cacheEntry.initialized() && cacheEntry.writing(), |
| 3194 | noHit); |
| 3195 | if (!cacheEntry.initialized()) { |
| 3196 | debug_printf("DWALPager(%s) issuing actual read of %s\n", filename.c_str(), toString(pageIDs).c_str()); |
| 3197 | cacheEntry.readFuture = forwardError(readPhysicalMultiPage(this, pageIDs, priority), errorPromise); |
| 3198 | cacheEntry.writeFuture = Void(); |
| 3199 | |
| 3200 | ++g_redwoodMetrics.metric.pagerCacheMiss; |
| 3201 | eventReasons.addEventReason(PagerEvents::CacheMiss, reason); |
| 3202 | } else { |
| 3203 | ++g_redwoodMetrics.metric.pagerCacheHit; |
| 3204 | eventReasons.addEventReason(PagerEvents::CacheHit, reason); |
| 3205 | } |
| 3206 | return cacheEntry.readFuture; |
| 3207 | } |
| 3208 | |
| 3209 | PhysicalPageID getPhysicalPageID(LogicalPageID pageID, Version v) { |
| 3210 | auto i = remappedPages.find(pageID); |
nothing calls this directly
no test coverage detected