Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce IOLimiter and remove background page cache flusher
The IOLimiter allows the CheckPointer to flush at a rate that is more sympathetic to other urgent tasks that need IO, such as appending to the transaction log during commit. The IOLimiter has, however, not yet been integrated with the CheckPointer. Removing the background flushing in the page cache also allows a change to the SequenceLock, to allow reads and writes to be concurrent with flushing. This has also not been implemented.
- Loading branch information
Showing
10 changed files
with
235 additions
and
259 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
community/io/src/main/java/org/neo4j/io/pagecache/IOLimiter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.io.pagecache; | ||
|
||
import java.io.Flushable; | ||
import java.io.IOException; | ||
|
||
/** | ||
* IOLimiter instances can be passed to the {@link PageCache#flushAndForce(IOLimiter)} and | ||
* {@link PagedFile#flushAndForce(IOLimiter)} methods, which will invoke the | ||
* {@link #maybeLimitIO(long, int, Flushable)} method on regular intervals. | ||
* <p> | ||
* This allows the limiter to measure the rate of IO, and inject sleeps, pauses or flushes into the process. | ||
* The flushes are in this case referring to the underlying hardware. | ||
* <p> | ||
* Normally, flushing a channel will just copy the dirty buffers into the OS page cache, but flushing is in this case | ||
* implying that the OS pages are cleared as well. In other words, the IOPSLimiter can make sure that the operating | ||
* system does not pile up too much IO work in its page cache, by flushing those caches as well on regular intervals. | ||
* <p> | ||
* The {@link #maybeLimitIO(long, int, Flushable)} method takes and returns a stamp long value. This allows the | ||
* implementations to become stateless with respect to the individual flush, yet still keep context from one call to | ||
* the next. | ||
*/ | ||
public interface IOLimiter | ||
{ | ||
/** | ||
* The value of the initial stamp; that is, what should be passed as the {@code previousStamp} to | ||
* {@link #maybeLimitIO(long, int, Flushable)} on the first call in a flush. | ||
*/ | ||
long INITIAL_STAMP = 0; | ||
|
||
/** | ||
* Invoked at regular intervals during flushing of the {@link PageCache} or {@link PagedFile}s. | ||
* | ||
* For the first call in a flush, the {@code previousStamp} should have the {@link #INITIAL_STAMP} value. | ||
* The return value of this method should then be used as the stamp of the next call. This allows implementations | ||
* to be stateless, yet still keep some context around about a given flush, provided they can encode it as a | ||
* {@code long}. | ||
* | ||
* The meaning of this long value is totally opaque to the caller, and can be anything the IOPSLimiter | ||
* implementation desires. | ||
* | ||
* The implementation is allowed to force changes to the storage device using the given {@link Flushable}, or | ||
* to perform {@link Thread#sleep(long) sleeps}, as it desires. It is not allowed to throw | ||
* {@link InterruptedException}, however. Those should be dealt with by catching them and re-interrupting the | ||
* current thread, or by wrapping them in {@link IOException}s. | ||
* @param previousStamp The stamp from the previous call to this method, or {@link #INITIAL_STAMP} if this is the | ||
* first call to this method for the given flush. | ||
* @param recentlyCompletedIOs The number of IOs completed since the last call to this method. | ||
* @param flushable A {@link Flushable} instance that can flush any relevant dirty system buffers, to help smooth | ||
* out the IO load on the storage device. | ||
* @return A new stamp to pass into the next call to this method. | ||
*/ | ||
long maybeLimitIO( long previousStamp, int recentlyCompletedIOs, Flushable flushable ) throws IOException; | ||
|
||
/** | ||
* An IOPSLimiter implementation that does not restrict the rate of IO. Use this implementation if you want the | ||
* flush to go as fast as possible. | ||
*/ | ||
static IOLimiter unlimited() | ||
{ | ||
return ( previousStamp, recentlyCompletedIOs, flushable ) -> 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/FlushTask.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.