@Override public void fixupCapacityOnLargeRead(ICachedPageInternal cPage) throws HyracksDataException { ByteBuffer oldBuffer = ((CachedPage) cPage).buffer; final int multiplier = cPage.getFrameSizeMultiplier(); final int newSize = pageSize * multiplier; final int delta = multiplier - 1; oldBuffer.position(0); ensureBudgetForLargePages(delta); ByteBuffer newBuffer = allocator.allocate(newSize, 1)[0]; newBuffer.put(oldBuffer); numPages.getAndAdd(delta); ((CachedPage) cPage).buffer = newBuffer; }
@Override public ICachedPageInternal findVictim() { return findVictim(1); }
@Override public void adviseWontNeed(ICachedPageInternal cPage) { //make the page appear as if it wasn't accessed even if it was getPerPageObject(cPage).set(false); }
public static IBufferCache getBufferCache(IIOManager ioManager) { if (bufferCache != null) { return bufferCache; } ICacheMemoryAllocator allocator = new HeapBufferAllocator(); IPageReplacementStrategy prs = new ClockPageReplacementStrategy(allocator, pageSize, numPages); IFileMapProvider fileMapProvider = getFileMapProvider(); bufferCache = new BufferCache(ioManager, prs, new DelayPageCleanerPolicy(1000), (IFileMapManager) fileMapProvider, maxOpenFiles, threadFactory); return bufferCache; } }
@Override public ICachedPageInternal findVictim(int multiplier) { while (numPages.get() + multiplier > maxAllowedNumPages) { // TODO: is dropping pages on the floor enough to adhere to memory budget? ICachedPageInternal victim = findVictimByEviction(); if (victim == null) { return null; } int multiple = victim.getFrameSizeMultiplier(); if (multiple == multiplier) { return victim; } else if (bufferCache.removePage(victim)) { cpIdFreeList.add(victim.getCachedPageId()); numPages.getAndAdd(-multiple); } } return allocatePage(multiplier); }
private ICachedPageInternal findVictimByEviction() { int clockPtr = advanceClock(); int startClockPtr = clockPtr; int lastClockPtr = -1; AtomicBoolean accessedFlag = getPerPageObject(cPage); if (!accessedFlag.compareAndSet(true, false)) { if (cPage.isGoodVictim()) { clockPtr = advanceClock();
private void ensureBudgetForLargePages(int delta) { while (numPages.get() + delta > maxAllowedNumPages) { ICachedPageInternal victim = findVictimByEviction(); if (victim != null) { final int victimMultiplier = victim.getFrameSizeMultiplier(); if (bufferCache.removePage(victim)) { cpIdFreeList.add(victim.getCachedPageId()); numPages.getAndAdd(-victimMultiplier); } } else { // we don't have the budget to resize- proceed anyway, but log if (LOGGER.isWarnEnabled()) { LOGGER.warn("Exceeding buffer cache budget of " + maxAllowedNumPages + " by " + (numPages.get() + delta - maxAllowedNumPages) + " pages in order to satisfy large page read"); } break; } } }
public RuntimeContext(INCServiceContext appCtx) throws HyracksDataException { fileMapManager = new FileMapManager(); ICacheMemoryAllocator allocator = new HeapBufferAllocator(); IPageReplacementStrategy prs = new ClockPageReplacementStrategy(allocator, 32768, 50); bufferCache = new BufferCache(appCtx.getIoManager(), prs, new DelayPageCleanerPolicy(1000), fileMapManager, 100, threadFactory); ILocalResourceRepositoryFactory localResourceRepositoryFactory = new TransientLocalResourceRepositoryFactory(); localResourceRepository = localResourceRepositoryFactory.createRepository(); resourceIdFactory = (new ResourceIdFactoryProvider(localResourceRepository)).createResourceIdFactory(); lcManager = new IndexLifecycleManager(); }
public RuntimeContext(INCApplicationContext appCtx) throws HyracksDataException { fileMapManager = new TransientFileMapManager(); ICacheMemoryAllocator allocator = new HeapBufferAllocator(); IPageReplacementStrategy prs = new ClockPageReplacementStrategy(allocator, 32768, 50); bufferCache = new BufferCache(appCtx.getRootContext().getIOManager(), prs, new DelayPageCleanerPolicy(1000), fileMapManager, 100, threadFactory); lcManager = new IndexLifecycleManager(); ILocalResourceRepositoryFactory localResourceRepositoryFactory = new TransientLocalResourceRepositoryFactory(); localResourceRepository = localResourceRepositoryFactory.createRepository(); resourceIdFactory = (new ResourceIdFactoryProvider(localResourceRepository)).createResourceIdFactory(); }
@Override public void notifyCachePageReset(ICachedPageInternal cPage) { getPerPageObject(cPage).set(false); }
ensureBudgetForLargePages(delta); if (origMultiplier != 1) {
ICacheMemoryAllocator allocator = new HeapBufferAllocator(); IPageCleanerPolicy pcp = new DelayPageCleanerPolicy(600000); IPageReplacementStrategy prs = new ClockPageReplacementStrategy(allocator, storageProperties.getBufferCachePageSize(), storageProperties.getBufferCacheNumPages()); lsmIOScheduler = new AsynchronousScheduler(getServiceContext().getThreadFactory(), HaltCallback.INSTANCE);
@Override public void notifyCachePageAccess(ICachedPageInternal cPage) { getPerPageObject(cPage).set(true); }