コード例 #1
0
        public static long DefaultHeuristicPageCacheMemory()
        {
            // First check if we have a default override...
            string defaultMemoryOverride = System.getProperty("dbms.pagecache.memory.default.override");

            if (!string.ReferenceEquals(defaultMemoryOverride, null))
            {
                return(BYTES.apply(defaultMemoryOverride));
            }

            double ratioOfFreeMem             = 0.50;
            string defaultMemoryRatioOverride = System.getProperty("dbms.pagecache.memory.ratio.default.override");

            if (!string.ReferenceEquals(defaultMemoryRatioOverride, null))
            {
                ratioOfFreeMem = double.Parse(defaultMemoryRatioOverride);
            }

            // Try to compute (RAM - maxheap) * 0.50 if we can get reliable numbers...
            long maxHeapMemory = Runtime.Runtime.maxMemory();

            if (0 < maxHeapMemory && maxHeapMemory < long.MaxValue)
            {
                try
                {
                    long physicalMemory = OsBeanUtil.TotalPhysicalMemory;
                    if (0 < physicalMemory && physicalMemory < long.MaxValue && maxHeapMemory < physicalMemory)
                    {
                        long heuristic = ( long )((physicalMemory - maxHeapMemory) * ratioOfFreeMem);
                        long min       = ByteUnit.mebiBytes(32);                               // We'd like at least 32 MiBs.
                        long max       = Math.Min(maxHeapMemory * 70, ByteUnit.gibiBytes(20));
                        // Don't heuristically take more than 20 GiBs, and don't take more than 70 times our max heap.
                        // 20 GiBs of page cache memory is ~2.6 million 8 KiB pages. If each page has an overhead of
                        // 72 bytes, then this will take up ~175 MiBs of heap memory. We should be able to tolerate that
                        // in most environments. The "no more than 70 times heap" heuristic is based on the page size over
                        // the per page overhead, 8192 / 72 ~= 114, plus leaving some extra room on the heap for the rest
                        // of the system. This means that we won't heuristically try to create a page cache that is too
                        // large to fit on the heap.
                        return(Math.Min(max, Math.Max(min, heuristic)));
                    }
                }
                catch (Exception)
                {
                }
            }
            // ... otherwise we just go with 2 GiBs.
            return(ByteUnit.gibiBytes(2));
        }
コード例 #2
0
ファイル: LargePageListIT.cs プロジェクト: Neo4Net/Neo4Net
//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));
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Void handle(org.neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request newEntryRequest) throws Exception
            public override Void Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request newEntryRequest)
            {
                BoundedNetworkWritableChannel sizeBoundChannel = new BoundedNetworkWritableChannel(Channel.byteBuf(), ByteUnit.gibiBytes(1));

                Marshal.marshal(newEntryRequest.Content(), sizeBoundChannel);
                return(null);
            }