예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reheatingMustWorkOnLargeNumberOfPages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReheatingMustWorkOnLargeNumberOfPages()
        {
            int maxPagesInMemory = 1_000;

            int[] pageIds = RandomSortedPageIds(maxPagesInMemory);

            string pageCacheMemory = (maxPagesInMemory * ByteUnit.kibiBytes(9)).ToString();

            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg.withMemory(pageCacheMemory)), PagedFile pf = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                using (PageCursor writer = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    foreach (int pageId in pageIds)
                    {
                        assertTrue(writer.Next(pageId));
                    }
                }
                pf.FlushAndForce();
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Profile();
            }

            long initialFaults = _cacheTracer.faults();

            ClearTracerCounts();
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize()))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Reheat();

                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + pageIds.Length));

                using (PageCursor reader = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK))
                {
                    foreach (int pageId in pageIds)
                    {
                        assertTrue(reader.Next(pageId));
                    }
                }

                // No additional faults must have been reported.
                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + pageIds.Length));
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void growEphemeralFileBuffer()
        internal virtual void GrowEphemeralFileBuffer()
        {
            EphemeralFileSystemAbstraction.DynamicByteBuffer byteBuffer = new EphemeralFileSystemAbstraction.DynamicByteBuffer();

            sbyte[] testBytes = new sbyte[] { 1, 2, 3, 4 };
            int     length    = testBytes.Length;

            byteBuffer.Put(0, testBytes, 0, length);
            assertEquals(( int )ByteUnit.kibiBytes(1), byteBuffer.Buf().capacity());

            byteBuffer.Put(( int )(ByteUnit.kibiBytes(1) + 2), testBytes, 0, length);
            assertEquals(( int )ByteUnit.kibiBytes(2), byteBuffer.Buf().capacity());

            byteBuffer.Put(( int )(ByteUnit.kibiBytes(5) + 2), testBytes, 0, length);
            assertEquals(( int )ByteUnit.kibiBytes(8), byteBuffer.Buf().capacity());

            byteBuffer.Put(( int )(ByteUnit.mebiBytes(2) + 2), testBytes, 0, length);
            assertEquals(( int )ByteUnit.mebiBytes(4), byteBuffer.Buf().capacity());
        }
예제 #3
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));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach public void setUp()
        public virtual void SetUp()
        {
            _tracer  = new DefaultPageCacheTracer();
            _swapper = new DummyPageSwapper("filename", ( int )ByteUnit.kibiBytes(8));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp()
        internal virtual void SetUp()
        {
            _cacheTracer      = new DefaultPageCacheTracer();
            _pageCursorTracer = CreateTracer();
            _swapper          = new DummyPageSwapper("filename", ( int )ByteUnit.kibiBytes(8));
        }
예제 #6
0
 public FixedLinkedStubPageCursorAnonymousInnerClass() : base(0, (int)ByteUnit.kibiBytes(4))
 {
 }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _recordFormat = new RelationshipGroupRecordFormat();
            _pageCursor   = new FixedLinkedStubPageCursor(0, ( int )ByteUnit.kibiBytes(8));
            _idSequence   = new ConstantIdSequence();
        }
예제 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @VisibleForTesting public CachingOffHeapBlockAllocator()
        public CachingOffHeapBlockAllocator() : this(ByteUnit.kibiBytes(512), 128)
        {
        }