Author: toad
Date: 2008-03-07 19:31:55 +0000 (Fri, 07 Mar 2008)
New Revision: 18416
Modified:
trunk/freenet/src/freenet/client/FetchContext.java
trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
One SerialExecutor per priority level.
This is still much less impact than we did have, with potentially dozens of
threads accessing the store in parallel when resuming requests; the worst case
is 7 now, and that will be very unusual.
Modified: trunk/freenet/src/freenet/client/FetchContext.java
===================================================================
--- trunk/freenet/src/freenet/client/FetchContext.java 2008-03-07 18:56:57 UTC
(rev 18415)
+++ trunk/freenet/src/freenet/client/FetchContext.java 2008-03-07 19:31:55 UTC
(rev 18416)
@@ -55,7 +55,7 @@
public Set allowedMIMETypes;
public final Ticker ticker;
public final Executor executor;
- public final Executor slowSerialExecutor;
+ public final Executor[] slowSerialExecutor;
public FetchContext(long curMaxLength,
long curMaxTempLength, int maxMetadataSize, int
maxRecursionLevel, int maxArchiveRestarts, int maxArchiveLevels,
@@ -66,7 +66,7 @@
RandomSource random, ArchiveManager archiveManager,
BucketFactory bucketFactory,
ClientEventProducer producer, boolean
cacheLocalRequests, USKManager uskManager,
HealingQueue hq, boolean ignoreTooManyPathComponents,
Ticker ticker, Executor executor,
- Executor slowSerialExecutor) {
+ Executor[] slowSerialExecutor) {
this.ticker = ticker;
this.executor = executor;
this.slowSerialExecutor = slowSerialExecutor;
Modified: trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
===================================================================
--- trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2008-03-07 18:56:57 UTC (rev 18415)
+++ trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2008-03-07 19:31:55 UTC (rev 18416)
@@ -49,7 +49,7 @@
private int curMaxMetadataLength;
private final RandomSource random;
private final HealingQueue healingQueue;
- private final Executor slowSerialExecutor;
+ private final Executor slowSerialExecutor[];
/** See comments in Node */
private final boolean cacheLocalRequests;
private final boolean forceDontIgnoreTooManyPathComponents;
@@ -85,7 +85,7 @@
static final int SPLITFILE_CHECK_BLOCKS_PER_SEGMENT = 64;
- public HighLevelSimpleClientImpl(NodeClientCore node, ArchiveManager
mgr, BucketFactory bf, RandomSource r, boolean cacheLocalRequests, short
priorityClass, boolean forceDontIgnoreTooManyPathComponents, Executor
slowSerialExecutor) {
+ public HighLevelSimpleClientImpl(NodeClientCore node, ArchiveManager
mgr, BucketFactory bf, RandomSource r, boolean cacheLocalRequests, short
priorityClass, boolean forceDontIgnoreTooManyPathComponents, Executor[]
slowSerialExecutor) {
this.core = node;
this.slowSerialExecutor = slowSerialExecutor;
archiveManager = mgr;
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-03-07 18:56:57 UTC (rev 18415)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-03-07 19:31:55 UTC (rev 18416)
@@ -284,7 +284,7 @@
}
public void scheduleOffThread() {
- fetchContext.slowSerialExecutor.execute(new Runnable() {
+
fetchContext.slowSerialExecutor[parent.priorityClass].execute(new Runnable() {
public void run() {
schedule();
}
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2008-03-07 18:56:57 UTC
(rev 18415)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2008-03-07 19:31:55 UTC
(rev 18416)
@@ -106,7 +106,7 @@
/** If true, requests are resumed lazily i.e. startup does not block
waiting for them. */
private boolean lazyResume;
protected final Persister persister;
- private final SerialExecutor clientSlowSerialExecutor;
+ private final SerialExecutor clientSlowSerialExecutor[];
public static int maxBackgroundUSKFetchers;
@@ -125,7 +125,14 @@
this.nodeStats = node.nodeStats;
this.random = node.random;
this.backgroundBlockEncoder = new BackgroundBlockEncoder();
- clientSlowSerialExecutor = new
SerialExecutor(NativeThread.LOW_PRIORITY);
+ clientSlowSerialExecutor = new
SerialExecutor[RequestStarter.MINIMUM_PRIORITY_CLASS-RequestStarter.MAXIMUM_PRIORITY_CLASS+1];
+ for(int i=0;i<clientSlowSerialExecutor.length;i++) {
+ int prio;
+ if(i <=
RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS) prio =
NativeThread.NORM_PRIORITY;
+ else if(i <= RequestStarter.UPDATE_PRIORITY_CLASS) prio
= NativeThread.LOW_PRIORITY;
+ else prio = NativeThread.MIN_PRIORITY;
+ clientSlowSerialExecutor[i] = new SerialExecutor(prio);
+ }
backgroundBlockEncoderThread = new
NativeThread(backgroundBlockEncoder, "Background block encoder",
NativeThread.MIN_PRIORITY, false);
backgroundBlockEncoderThread.setDaemon(true);
byte[] pwdBuf = new byte[16];
@@ -416,9 +423,10 @@
fcpServer.maybeStart();
if(tmci != null)
tmci.start();
- clientSlowSerialExecutor.start(node.executor, "Heavy client
jobs runner");
+ for(int i=0;i<clientSlowSerialExecutor.length;i++)
+ clientSlowSerialExecutor[i].start(node.executor, "Heavy
client jobs runner ("+i+")");
- clientSlowSerialExecutor.execute(new Runnable() {
+ node.executor.execute(new Runnable() {
public void run() {
System.out.println("Resuming persistent
requests");
Logger.normal(this, "Resuming persistent
requests");