Beispiel #1
0
        /// <summary>
        /// Opens a new <seealso cref="PageCache"/> with the provided file system and config.
        /// </summary>
        /// <param name="fs"> <seealso cref="FileSystemAbstraction"/> to use for the <seealso cref="PageCache"/>. </param>
        /// <param name="overriddenConfig"> specific <seealso cref="PageCacheConfig"/> overriding config provided in <seealso cref="PageCacheRule"/>
        /// constructor, if any. </param>
        /// <returns> the opened <seealso cref="PageCache"/>. </returns>
        public virtual PageCache GetPageCache(FileSystemAbstraction fs, PageCacheConfig overriddenConfig)
        {
            CloseExistingPageCache();
            int?                     pageSize             = SelectConfig(BaseConfig.pageSize, overriddenConfig.PageSize, null);
            PageCacheTracer          cacheTracer          = SelectConfig(BaseConfig.tracer, overriddenConfig.Tracer, PageCacheTracer.NULL);
            PageCursorTracerSupplier cursorTracerSupplier = SelectConfig(BaseConfig.pageCursorTracerSupplier, overriddenConfig.PageCursorTracerSupplier, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null);

            SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory();

            factory.Open(fs, Configuration.EMPTY);
            VersionContextSupplier contextSupplier = EmptyVersionContextSupplier.EMPTY;
            MemoryAllocator        mman            = MemoryAllocator.createAllocator(SelectConfig(BaseConfig.memory, overriddenConfig.Memory, "8 MiB"), new LocalMemoryTracker());

            InitializeJobScheduler();
            if (pageSize != null)
            {
                PageCache = new MuninnPageCache(factory, mman, pageSize.Value, cacheTracer, cursorTracerSupplier, contextSupplier, JobScheduler);
            }
            else
            {
                PageCache = new MuninnPageCache(factory, mman, cacheTracer, cursorTracerSupplier, contextSupplier, JobScheduler);
            }
            PageCachePostConstruct(overriddenConfig);
            return(PageCache);
        }
Beispiel #2
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();
        }
 protected internal T GetPageCache(FileSystemAbstraction fs, int maxPages, PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier)
 {
     if (PageCache != null)
     {
         TearDownPageCache(PageCache);
     }
     PageCache = CreatePageCache(fs, maxPages, tracer, cursorTracerSupplier, EmptyVersionContextSupplier.EMPTY);
     return(PageCache);
 }
Beispiel #4
0
 /// <summary>
 /// Construct configuring page cache factory </summary>
 /// <param name="fs"> fileSystem file system that page cache will be based on </param>
 /// <param name="config"> page swapper configuration </param>
 /// <param name="pageCacheTracer"> global page cache tracer </param>
 /// <param name="pageCursorTracerSupplier"> supplier of thread local (transaction local) page cursor tracer that will provide
 /// thread local page cache statistics </param>
 /// <param name="log"> page cache factory log </param>
 /// <param name="versionContextSupplier"> cursor context factory </param>
 /// <param name="scheduler"> job scheduler to execute page cache jobs </param>
 public ConfiguringPageCacheFactory(FileSystemAbstraction fs, Config config, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, Log log, VersionContextSupplier versionContextSupplier, JobScheduler scheduler)
 {
     this._fs = fs;
     this._versionContextSupplier = versionContextSupplier;
     this._config                   = config;
     this._pageCacheTracer          = pageCacheTracer;
     this._log                      = log;
     this._pageCursorTracerSupplier = pageCursorTracerSupplier;
     this._scheduler                = scheduler;
 }
Beispiel #5
0
        /// <summary>
        /// Create a Tracers subsystem with the desired implementation, if it can be found and created.
        ///
        /// Otherwise the default implementation is used, and a warning is logged to the given StringLogger. </summary>
        /// <param name="desiredImplementationName"> The name of the desired {@link org.neo4j.kernel.monitoring.tracing
        /// .TracerFactory} implementation, as given by its <seealso cref="TracerFactory.getImplementationName()"/> method. </param>
        /// <param name="msgLog"> A <seealso cref="Log"/> for logging when the desired implementation cannot be created. </param>
        /// <param name="monitors"> the monitoring manager </param>
        /// <param name="jobScheduler"> a scheduler for async jobs </param>
        public Tracers(string desiredImplementationName, Log msgLog, Monitors monitors, JobScheduler jobScheduler, SystemNanoClock clock)
        {
            if ("null".Equals(desiredImplementationName, StringComparison.OrdinalIgnoreCase))
            {
                PageCursorTracerSupplier = DefaultPageCursorTracerSupplier.NULL;
                PageCacheTracer          = PageCacheTracer.NULL;
                TransactionTracer        = Org.Neo4j.Kernel.impl.transaction.tracing.TransactionTracer_Fields.Null;
                CheckPointTracer         = Org.Neo4j.Kernel.impl.transaction.tracing.CheckPointTracer_Fields.Null;
                LockTracer = LockTracer.NONE;
            }
            else
            {
                TracerFactory foundFactory = new DefaultTracerFactory();
                bool          found        = string.ReferenceEquals(desiredImplementationName, null);
                foreach (TracerFactory factory in Service.load(typeof(TracerFactory)))
                {
                    try
                    {
                        if (factory.ImplementationName.Equals(desiredImplementationName, StringComparison.OrdinalIgnoreCase))
                        {
                            foundFactory = factory;
                            found        = true;
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        msgLog.Warn("Failed to instantiate desired tracer implementations '" + desiredImplementationName + "'", e);
                    }
                }

                if (!found)
                {
                    msgLog.Warn("Using default tracer implementations instead of '%s'", desiredImplementationName);
                }

                PageCursorTracerSupplier = foundFactory.CreatePageCursorTracerSupplier(monitors, jobScheduler);
                PageCacheTracer          = foundFactory.CreatePageCacheTracer(monitors, jobScheduler, clock, msgLog);
                TransactionTracer        = foundFactory.CreateTransactionTracer(monitors, jobScheduler);
                CheckPointTracer         = foundFactory.CreateCheckPointTracer(monitors, jobScheduler);
                LockTracer = foundFactory.CreateLockTracer(monitors, jobScheduler);
            }
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 60_000) @RepeatRule.Repeat(times = 5) public void pageCacheCountersAreSumOfPageCursorCounters() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PageCacheCountersAreSumOfPageCursorCounters()
        {
            IList <NodeCreator> nodeCreators       = new List <NodeCreator>(_numberOfWorkers);
            IList <Future>      nodeCreatorFutures = new List <Future>(_numberOfWorkers);
            PageCacheTracer     pageCacheTracer    = GetPageCacheTracer(_db);

            long initialPins         = pageCacheTracer.Pins();
            long initialHits         = pageCacheTracer.Hits();
            long initialUnpins       = pageCacheTracer.Unpins();
            long initialBytesRead    = pageCacheTracer.BytesRead();
            long initialBytesWritten = pageCacheTracer.BytesWritten();
            long initialEvictions    = pageCacheTracer.Evictions();
            long initialFaults       = pageCacheTracer.Faults();
            long initialFlushes      = pageCacheTracer.Flushes();

            StartNodeCreators(nodeCreators, nodeCreatorFutures);
            while (pageCacheTracer.Pins() == 0 || pageCacheTracer.Faults() == 0 || pageCacheTracer.Unpins() == 0)
            {
                TimeUnit.MILLISECONDS.sleep(10);
            }
            StopNodeCreators(nodeCreators, nodeCreatorFutures);

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of pins events in page cache tracer should equal to the sum of pin events in " + "page cursor tracers.", pageCacheTracer.Pins(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getPins, initialPins)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of unpins events in page cache tracer should equal to the sum of unpin events in " + "page cursor tracers.", pageCacheTracer.Unpins(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getUnpins, initialUnpins)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of initialBytesRead in page cache tracer should equal to the sum of initialBytesRead " + "in page cursor tracers.", pageCacheTracer.BytesRead(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getBytesRead, initialBytesRead)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of bytesWritten in page cache tracer should equal to the sum of bytesWritten in " + "page cursor tracers.", pageCacheTracer.BytesWritten(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getBytesWritten, initialBytesWritten)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of evictions in page cache tracer should equal to the sum of evictions in " + "page cursor tracers.", pageCacheTracer.Evictions(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getEvictions, initialEvictions)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of faults in page cache tracer should equal to the sum of faults in page cursor tracers.", pageCacheTracer.Faults(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getFaults, initialFaults)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of flushes in page cache tracer should equal to the sum of flushes in page cursor tracers.", pageCacheTracer.Flushes(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getFlushes, initialFlushes)));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat("Number of hits in page cache tracer should equal to the sum of hits in page cursor tracers.", pageCacheTracer.Hits(), greaterThanOrEqualTo(SumCounters(nodeCreators, NodeCreator::getHits, initialHits)));
        }
 public override void Init(PageCacheTracer pageCacheTracer)
 {
     this._pageCacheTracer = pageCacheTracer;
 }
 public abstract T CreatePageCache(PageSwapperFactory swapperFactory, int maxPages, PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier, VersionContextSupplier contextSupplier, JobScheduler jobScheduler);
 protected internal virtual T CreatePageCache(FileSystemAbstraction fs, int maxPages, PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier)
 {
     return(CreatePageCache(fs, maxPages, tracer, cursorTracerSupplier, EmptyVersionContextSupplier.EMPTY));
 }
Beispiel #10
0
        protected internal virtual T CreatePageCache(FileSystemAbstraction fs, int maxPages, PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier, VersionContextSupplier versionContextSupplier)
        {
            PageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory();

            swapperFactory.Open(fs, Configuration.EMPTY);
            return(CreatePageCache(swapperFactory, maxPages, tracer, cursorTracerSupplier, versionContextSupplier));
        }
Beispiel #11
0
 /// <summary>
 /// Create page cache. </summary>
 /// <param name="swapperFactory"> page cache swapper factory </param>
 /// <param name="memoryAllocator"> the source of native memory the page cache should use </param>
 /// <param name="pageCacheTracer"> global page cache tracer </param>
 /// <param name="pageCursorTracerSupplier"> supplier of thread local (transaction local) page cursor tracer that will provide
 /// thread local page cache statistics </param>
 /// <param name="versionContextSupplier"> supplier of thread local (transaction local) version context that will provide
 ///        access to thread local version context </param>
 public MuninnPageCache(PageSwapperFactory swapperFactory, MemoryAllocator memoryAllocator, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, VersionContextSupplier versionContextSupplier, JobScheduler jobScheduler) : this(swapperFactory, memoryAllocator, org.neo4j.io.pagecache.PageCache_Fields.PAGE_SIZE, pageCacheTracer, pageCursorTracerSupplier, versionContextSupplier, jobScheduler)
 {
 }
Beispiel #12
0
 /// <summary>
 /// <seealso cref="PageCacheTracer"/> to use for the PageCache.
 /// </summary>
 /// <param name="tracer"> <seealso cref="PageCacheTracer"/> to use. </param>
 /// <returns> this instance. </returns>
 public PageCacheConfig WithTracer(PageCacheTracer tracer)
 {
     this.Tracer = tracer;
     return(this);
 }
Beispiel #13
0
 public DelegatingPageCacheTracerAnonymousInnerClass(MuninnPageCacheTest outerInstance, PageCacheTracer @delegate) : base(@delegate)
 {
     this.outerInstance = outerInstance;
 }
Beispiel #14
0
 private PageCacheTracer BlockCacheFlush(PageCacheTracer @delegate)
 {
     _fixture.backgroundFlushLatch = new System.Threading.CountdownEvent(1);
     return(new DelegatingPageCacheTracerAnonymousInnerClass(this, @delegate));
 }
 public override void Init(PageCacheTracer tracer)
 {
     this._tracer = tracer;
 }
 public DelegatingPageCacheTracer(PageCacheTracer @delegate)
 {
     this.@delegate = @delegate;
 }
Beispiel #17
0
        protected internal T CreatePageCache(PageSwapperFactory swapperFactory, int maxPages, PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier, VersionContextSupplier versionContextSupplier)
        {
            T pageCache = _fixture.createPageCache(swapperFactory, maxPages, tracer, cursorTracerSupplier, versionContextSupplier, JobScheduler);

            PageCachePageSize  = pageCache.PageSize();
            RecordsPerFilePage = PageCachePageSize / RecordSize;
            RecordCount        = 5 * maxPages * RecordsPerFilePage;
            FilePageSize       = RecordsPerFilePage * RecordSize;
            BufA = ByteBuffer.allocate(RecordSize);
            return(pageCache);
        }
Beispiel #18
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));
        }
Beispiel #19
0
 /// <summary>
 /// Create page cache. </summary>
 /// <param name="swapperFactory"> page cache swapper factory </param>
 /// <param name="maxPages"> maximum number of pages </param>
 /// <param name="pageCacheTracer"> global page cache tracer </param>
 /// <param name="pageCursorTracerSupplier"> supplier of thread local (transaction local) page cursor tracer that will provide
 /// thread local page cache statistics </param>
 /// <param name="versionContextSupplier"> supplier of thread local (transaction local) version context that will provide
 /// access to thread local version context </param>
 public MuninnPageCache(PageSwapperFactory swapperFactory, int maxPages, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, VersionContextSupplier versionContextSupplier, JobScheduler jobScheduler) : this(swapperFactory, MemoryAllocator.createAllocator("" + MemoryRequiredForPages(maxPages), GlobalMemoryTracker.INSTANCE), org.neo4j.io.pagecache.PageCache_Fields.PAGE_SIZE, pageCacheTracer, pageCursorTracerSupplier, versionContextSupplier, jobScheduler)
 {
 }