Beispiel #1
0
        public MuninnPageCache(PageSwapperFactory swapperFactory, MemoryAllocator memoryAllocator, int cachePageSize, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, VersionContextSupplier versionContextSupplier, JobScheduler jobScheduler)
        {
            VerifyHacks();
            VerifyCachePageSizeIsPowerOfTwo(cachePageSize);
            int maxPages = CalculatePageCount(memoryAllocator, cachePageSize);

            // Expose the total number of pages
            pageCacheTracer.MaxPages(maxPages);
            MemoryAllocationTracker memoryTracker = GlobalMemoryTracker.INSTANCE;

            this._pageCacheId              = _pageCacheIdCounter.incrementAndGet();
            this._swapperFactory           = swapperFactory;
            this._cachePageSize            = cachePageSize;
            this._keepFree                 = Math.Min(_pagesToKeepFree, maxPages / 2);
            this._pageCacheTracer          = pageCacheTracer;
            this._pageCursorTracerSupplier = pageCursorTracerSupplier;
            this._versionContextSupplier   = versionContextSupplier;
            this._printExceptionsOnClose   = true;
            long alignment = swapperFactory.RequiredBufferAlignment;

            this.VictimPage = VictimPageReference.GetVictimPage(cachePageSize, memoryTracker);
            this.Pages      = new PageList(maxPages, cachePageSize, memoryAllocator, new SwapperSet(), VictimPage, alignment);
            this._scheduler = jobScheduler;

            FreelistHead = new AtomicInteger();
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void veryLargePageListsMustBeFullyAccessible()
        internal virtual void VeryLargePageListsMustBeFullyAccessible()
        {
            // We need roughly 2 GiBs of memory for the meta-data here, which is why this is an IT and not a Test.
            // We add one extra page worth of data to the size here, to avoid ending up on a "convenient" boundary.
            int  pageSize      = ( int )ByteUnit.kibiBytes(8);
            long pageCacheSize = ByteUnit.gibiBytes(513) + pageSize;
            int  pages         = Math.toIntExact(pageCacheSize / pageSize);

            MemoryAllocator mman       = MemoryAllocator.createAllocator("2 GiB", GlobalMemoryTracker.INSTANCE);
            SwapperSet      swappers   = new SwapperSet();
            long            victimPage = VictimPageReference.GetVictimPage(pageSize, GlobalMemoryTracker.INSTANCE);

            PageList pageList = new PageList(pages, pageSize, mman, swappers, victimPage, Long.BYTES);

            // Verify we end up with the correct number of pages.
            assertThat(pageList.PageCount, @is(pages));

            // Spot-check the accessibility in the bulk of the pages.
            IntStream.range(0, pages / 32).parallel().forEach(id => verifyPageMetaDataIsAccessible(pageList, id * 32));

            // Thoroughly check the accessibility around the tail end of the page list.
            IntStream.range(pages - 2000, pages).parallel().forEach(id => verifyPageMetaDataIsAccessible(pageList, id));
        }