Author: toad
Date: 2008-01-28 17:18:09 +0000 (Mon, 28 Jan 2008)
New Revision: 17368
Modified:
trunk/freenet/src/freenet/client/FECCodec.java
trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
Log:
Add some Thread.yield()s.
Unfortunately this seems to be necessary: on Linux/AMD64, java 1.5.0_13 (or
perhaps linux?) ignores thread priorities, and linux 2.6.23's fair scheduling
doesn't seem to guarantee critical threads don't get starved on startup either.
:(
Modified: trunk/freenet/src/freenet/client/FECCodec.java
===================================================================
--- trunk/freenet/src/freenet/client/FECCodec.java 2008-01-28 17:05:46 UTC
(rev 17367)
+++ trunk/freenet/src/freenet/client/FECCodec.java 2008-01-28 17:18:09 UTC
(rev 17368)
@@ -163,6 +163,13 @@
if(writers[i] != null)
writers[i].write(realBuffer, i * STRIPE_SIZE,
STRIPE_SIZE);
+
+ // FIXME unfortunately this seems to be
necessary on *nix to prevent
+ // critical threads from starving:
sadly thread priorities only work on
+ // Windows and as of linux 2.6.23, fair
scheduling does not ensure that
+ // the critical threads (those which
set MAX_PRIORITY) get enough CPU time.
+ Thread.yield();
+
}
}
@@ -291,6 +298,13 @@
if(writers[i - k] != null)
writers[i -
k].write(realBuffer, i * STRIPE_SIZE,
STRIPE_SIZE);
+
+ // FIXME unfortunately this seems to be
necessary on *nix to prevent
+ // critical threads from starving:
sadly thread priorities only work on
+ // Windows and as of linux 2.6.23, fair
scheduling does not ensure that
+ // the critical threads (those which
set MAX_PRIORITY) get enough CPU time.
+ Thread.yield();
+
}
}
Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-01-28 17:05:46 UTC (rev 17367)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-01-28 17:18:09 UTC (rev 17368)
@@ -231,6 +231,11 @@
if(block != null) {
if(logMINOR) Logger.minor(this,
"Can fulfill "+req+" ("+tok+") immediately from store");
getter.onSuccess(block, true,
tok);
+ // FIXME unfortunately this
seems to be necessary on *nix to prevent
+ // critical threads from
starving: sadly thread priorities only work on
+ // Windows and as of linux
2.6.23, fair scheduling does not ensure that
+ // the critical threads (those
which set MAX_PRIORITY) get enough CPU time.
+ Thread.yield();
} else {
anyValid = true;
}
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-01-28 17:05:46 UTC (rev 17367)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-01-28 17:18:09 UTC (rev 17368)
@@ -187,6 +187,11 @@
SplitFileFetcherSegment s = segments[i];
long max = (finalLength < 0 ? 0 : (finalLength
- bytesWritten));
bytesWritten += s.writeDecodedDataTo(os, max);
+ // FIXME unfortunately this seems to be
necessary on *nix to prevent
+ // critical threads from starving: sadly thread
priorities only work on
+ // Windows and as of linux 2.6.23, fair
scheduling does not ensure that
+ // the critical threads (those which set
MAX_PRIORITY) get enough CPU time.
+ Thread.yield();
}
} catch (IOException e) {
throw new FetchException(FetchException.BUCKET_ERROR,
e);