[freenet-cvs] r20976 - branches/db4o/freenet/src/freenet/client/async
toad at freenetproject.org
toad at freenetproject.org
Fri Jul 4 13:31:17 UTC 2008
Author: toad
Date: 2008-07-04 13:31:17 +0000 (Fri, 04 Jul 2008)
New Revision: 20976
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
Log:
Optimisation: Select up to 50 requests from a single SendableRequest in requestStarterQueueFiller.
This will significantly reduce database I/O... I hope.
Profiling (via the PrioritizedSerialExecutor class time logging code) shows that requestStarterQueueFiller is a *large* proportion of the total time.
On my (relatively powerful) system, I am seeing the normal priority (5) queue increasing indefinitely...
Modified: branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java 2008-07-04 13:24:24 UTC (rev 20975)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java 2008-07-04 13:31:17 UTC (rev 20976)
@@ -513,6 +513,9 @@
}
}
+ /** Maximum number of requests to select from a single SendableRequest */
+ final int MAX_CONSECUTIVE_SAME_REQ = 50;
+
private DBJob requestStarterQueueFiller = new DBJob() {
public void run(ObjectContainer container, ClientContext context) {
if(logMINOR) Logger.minor(this, "Filling request queue... (SSK="+isSSKScheduler+" insert="+isInsertScheduler);
@@ -529,8 +532,19 @@
return;
}
}
+ SendableRequest lastReq = null;
+ int sameKey = 0;
while(true) {
- req = removeFirst(container, false, true);
+ req = null;
+ if(lastReq != null && sameKey < MAX_CONSECUTIVE_SAME_REQ) {
+ req = schedCore.maybeMakeChosenRequest(lastReq, container, context);
+ sameKey++;
+ }
+ if(req == null) {
+ req = removeFirst(container, false, true);
+ if(sameKey > 1)
+ Logger.error(this, "Selected "+sameKey+" requests from same SendableRequest: "+lastReq);
+ }
if(req == null) return;
container.activate(req.key, 5);
container.activate(req.ckey, 5);
Modified: branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java 2008-07-04 13:24:24 UTC (rev 20975)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java 2008-07-04 13:31:17 UTC (rev 20976)
@@ -241,6 +241,10 @@
// The worry is ... is there any nested locking outside of the hierarchy?
ChosenRequest removeFirst(int fuzz, RandomSource random, OfferedKeysList[] offeredKeys, RequestStarter starter, ClientRequestSchedulerNonPersistent schedTransient, boolean transientOnly, boolean notTransient, short maxPrio, int retryCount, ClientContext context, ObjectContainer container) {
SendableRequest req = removeFirstInner(fuzz, random, offeredKeys, starter, schedTransient, transientOnly, notTransient, maxPrio, retryCount, context, container);
+ return maybeMakeChosenRequest(req, container, context);
+ }
+
+ public ChosenRequest maybeMakeChosenRequest(SendableRequest req, ObjectContainer container, ClientContext context) {
if(req == null) return null;
Object token = req.chooseKey(this, req.persistent() ? container : null, context);
if(token == null) {
More information about the cvs
mailing list