Author: toad
Date: 2008-02-15 16:30:27 +0000 (Fri, 15 Feb 2008)
New Revision: 17948
Modified:
trunk/freenet/src/freenet/crypt/DiffieHellman.java
trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
trunk/freenet/src/freenet/node/PacketSender.java
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
trunk/freenet/src/freenet/support/Executor.java
trunk/freenet/src/freenet/support/PooledExecutor.java
trunk/freenet/src/freenet/support/io/NativeThread.java
Log:
Pass in a flag to executor if we are running from the ticker.
Don't check the niceness for renicing unless we are.
Enables us to continue to run immediate jobs from off the ticker.
Modified: trunk/freenet/src/freenet/crypt/DiffieHellman.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DiffieHellman.java 2008-02-15 16:19:22 UTC
(rev 17947)
+++ trunk/freenet/src/freenet/crypt/DiffieHellman.java 2008-02-15 16:30:27 UTC
(rev 17948)
@@ -49,7 +49,7 @@
private static class PrecalcBufferFill extends NativeThread {
public PrecalcBufferFill() {
- super("Diffie-Hellman-Precalc", Thread.MIN_PRIORITY);
+ super("Diffie-Hellman-Precalc", Thread.MIN_PRIORITY,
false);
setDaemon(true);
}
Modified: trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java 2008-02-15
16:19:22 UTC (rev 17947)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java 2008-02-15
16:30:27 UTC (rev 17948)
@@ -45,7 +45,7 @@
private boolean _started;
public UdpSocketHandler(int listenPort, InetAddress bindto, Node node,
long startupTime, String title) throws SocketException {
- super("UDP packet receiver for "+title, Thread.MAX_PRIORITY);
+ super("UDP packet receiver for "+title, Thread.MAX_PRIORITY,
false);
this.node = node;
this.title = title;
_bindTo = bindto;
Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java 2008-02-15 16:19:22 UTC
(rev 17947)
+++ trunk/freenet/src/freenet/node/PacketSender.java 2008-02-15 16:30:27 UTC
(rev 17948)
@@ -418,7 +418,7 @@
}
else
try {
- node.executor.execute(r,
"Scheduled job: " + r);
+ node.executor.execute(r,
"Scheduled job: " + r, Thread.NORM_PRIORITY, true);
} catch(OutOfMemoryError e) {
OOMHandler.handleOOM(e);
System.err.println("Will retry
above failed operation...");
Modified:
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-02-15 16:19:22 UTC (rev 17947)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-02-15 16:30:27 UTC (rev 17948)
@@ -34,15 +34,15 @@
*/
public class RealNodeRequestInsertTest extends RealNodeRoutingTest {
- static final int NUMBER_OF_NODES = 25;
+ static final int NUMBER_OF_NODES = 50;
static final int DEGREE = 5;
static final short MAX_HTL = (short)10;
static final boolean START_WITH_IDEAL_LOCATIONS = false;
- static final boolean FORCE_NEIGHBOUR_CONNECTIONS = false;
+ static final boolean FORCE_NEIGHBOUR_CONNECTIONS = true;
static final boolean ENABLE_SWAPPING = true;
static final boolean ENABLE_ULPRS = false;
static final boolean ENABLE_PER_NODE_FAILURE_TABLES = false;
- static final boolean ENABLE_SWAP_QUEUEING = true;
+ static final boolean ENABLE_SWAP_QUEUEING = false;
static final boolean ENABLE_PACKET_COALESCING = false;
static final int TARGET_SUCCESSES = 20;
@@ -70,7 +70,7 @@
Executor executor = new PooledExecutor();
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5001+i, name, false, true, true,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
+ NodeStarter.createTestNode(6001+i, name, false, true, true,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
Modified: trunk/freenet/src/freenet/support/Executor.java
===================================================================
--- trunk/freenet/src/freenet/support/Executor.java 2008-02-15 16:19:22 UTC
(rev 17947)
+++ trunk/freenet/src/freenet/support/Executor.java 2008-02-15 16:30:27 UTC
(rev 17948)
@@ -11,6 +11,7 @@
/** Execute a job. */
public void execute(Runnable job, String jobName);
public void execute(Runnable job, String jobName, int priority);
+ public void execute(Runnable job, String jobName, int priority, boolean
fromTicker);
/** Count the number of threads waiting for work */
public int[] waitingThreads();
Modified: trunk/freenet/src/freenet/support/PooledExecutor.java
===================================================================
--- trunk/freenet/src/freenet/support/PooledExecutor.java 2008-02-15
16:19:22 UTC (rev 17947)
+++ trunk/freenet/src/freenet/support/PooledExecutor.java 2008-02-15
16:30:27 UTC (rev 17948)
@@ -47,6 +47,10 @@
}
public void execute(Runnable job, String jobName, int prio) {
+ execute(job, jobName, prio, false);
+ }
+
+ public void execute(Runnable job, String jobName, int prio, boolean
fromTicker) {
if(logMINOR) Logger.minor(this, "Executing "+job+" as
"+jobName+" at prio "+prio);
while(true) {
MyThread t;
@@ -58,13 +62,13 @@
t = (MyThread)
waitingThreads[prio].remove(waitingThreads[prio].size()-1);
} else {
// Must create new thread
- if(NativeThread.usingNativeCode() &&
prio < Thread.currentThread().getPriority()) {
+ if((!fromTicker) &&
NativeThread.usingNativeCode() && prio < Thread.currentThread().getPriority()) {
// Run on ticker
ticker.queueTimedJob(job, 0);
return;
}
// Will be coalesced by thread count
listings if we use "@" or "for"
- t = new MyThread("Pooled thread
awaiting work @"+(threadCounter[prio]++), threadCounter[prio], prio);
+ t = new MyThread("Pooled thread
awaiting work @"+(threadCounter[prio]++), threadCounter[prio], prio,
!fromTicker);
t.setDaemon(true);
mustStart = true;
miss = true;
@@ -108,8 +112,8 @@
Runnable nextJob;
final long threadNo;
- public MyThread(String defaultName, long threadCounter, int
prio) {
- super(defaultName, prio);
+ public MyThread(String defaultName, long threadCounter, int
prio, boolean dontCheckRenice) {
+ super(defaultName, prio, dontCheckRenice);
this.defaultName = defaultName;
threadNo = threadCounter;
}
Modified: trunk/freenet/src/freenet/support/io/NativeThread.java
===================================================================
--- trunk/freenet/src/freenet/support/io/NativeThread.java 2008-02-15
16:19:22 UTC (rev 17947)
+++ trunk/freenet/src/freenet/support/io/NativeThread.java 2008-02-15
16:30:27 UTC (rev 17948)
@@ -25,6 +25,7 @@
private static int NATIVE_PRIORITY_BASE;
public static int NATIVE_PRIORITY_RANGE;
private int currentPriority = Thread.MAX_PRIORITY;
+ private boolean dontCheckRenice = false;
public static boolean HAS_THREE_NICE_LEVELS;
public static boolean HAS_ENOUGH_NICE_LEVELS;
@@ -95,9 +96,10 @@
}
}
- public NativeThread(String name, int priority) {
+ public NativeThread(String name, int priority, boolean dontCheckRenice)
{
super(name);
this.currentPriority = priority;
+ this.dontCheckRenice = dontCheckRenice;
}
public NativeThread(Runnable r, String name, int priority) {
@@ -143,7 +145,7 @@
Logger.normal(this, "Not setting native priority as
disabled due to renicing");
return false;
}
- if(NATIVE_PRIORITY_BASE != realPrio) {
+ if(NATIVE_PRIORITY_BASE != realPrio && !dontCheckRenice) {
/* The user has reniced freenet or we didn't use the
PacketSender to create the thread
* either ways it's bad for us.
*
@@ -156,6 +158,7 @@
return false;
}
final int linuxPriority = NATIVE_PRIORITY_BASE +
NATIVE_PRIORITY_RANGE - (NATIVE_PRIORITY_RANGE * (prio - MIN_PRIORITY)) /
JAVA_PRIO_RANGE;
+ if(linuxPriority == realPrio) return true; // Ok
// That's an obvious coding mistake
if(prio < currentPriority)
throw new IllegalStateException("You're trying to set a
thread priority" +