* Startup:

- Enable multiple parallel job runners much sooner to speed startup
      - Rearrange the startup order to get the long jobs started sooner
      - Don't allow the netDb readin job to clog the job queue
This commit is contained in:
zzz
2010-01-23 19:12:37 +00:00
parent 66d8fd6c2a
commit 5dda915467
5 changed files with 53 additions and 18 deletions

View File

@@ -346,8 +346,12 @@ class PersistentDataStore extends TransientDataStore {
_alreadyWarned = false;
for (int i = 0; i < routerInfoFiles.length; i++) {
Hash key = getRouterInfoHash(routerInfoFiles[i].getName());
if ( (key != null) && (!isKnown(key)) )
PersistentDataStore.this._context.jobQueue().addJob(new ReadRouterJob(routerInfoFiles[i], key));
if ( (key != null) && (!isKnown(key)) ) {
// Run it inline so we don't clog up the job queue, esp. at startup
// Also this allows us to wait until it is really done to call checkReseed() and set _initialized
//PersistentDataStore.this._context.jobQueue().addJob(new ReadRouterJob(routerInfoFiles[i], key));
(new ReadRouterJob(routerInfoFiles[i], key)).runJob();
}
}
}
} catch (IOException ioe) {

View File

@@ -13,6 +13,7 @@ import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
/** This actually boots almost everything */
public class BootCommSystemJob extends JobImpl {
private Log _log;
@@ -26,18 +27,29 @@ public class BootCommSystemJob extends JobImpl {
public String getName() { return "Boot Communication System"; }
public void runJob() {
// The netDb and the peer manager both take a long time to start up,
// as they may have to read in ~1000 files or more each
// So turn on the multiple job queues and start these two first.
// These two (plus the current job) will consume 3 of the 4 runners,
// leaving one for everything else, which allows us to start without
// a huge job lag displayed on the console.
getContext().jobQueue().allowParallelOperation();
startupDb();
getContext().jobQueue().addJob(new BootPeerManagerJob(getContext()));
// start up the network comm system
getContext().commSystem().startup();
getContext().tunnelManager().startup();
getContext().peerManager().startup();
// start I2CP
getContext().jobQueue().addJob(new StartAcceptingClientsJob(getContext()));
getContext().jobQueue().addJob(new ReadConfigJob(getContext()));
}
private void startupDb() {
Job bootDb = new BootNetworkDbJob(getContext());
boolean useTrusted = false;
String useTrustedStr = getContext().router().getConfigSetting(PROP_USE_TRUSTED_LINKS);
if (useTrustedStr != null) {
useTrusted = Boolean.TRUE.toString().equalsIgnoreCase(useTrustedStr);
}
boolean useTrusted = Boolean.valueOf(getContext().getProperty(PROP_USE_TRUSTED_LINKS)).booleanValue();
if (useTrusted) {
_log.debug("Using trusted links...");
getContext().jobQueue().addJob(new BuildTrustedLinksJob(getContext(), bootDb));

View File

@@ -10,10 +10,9 @@ package net.i2p.router.startup;
import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
/** start up the network database */
public class BootNetworkDbJob extends JobImpl {
private static Log _log = new Log(BootNetworkDbJob.class);
public BootNetworkDbJob(RouterContext ctx) {
super(ctx);
@@ -22,10 +21,6 @@ public class BootNetworkDbJob extends JobImpl {
public String getName() { return "Boot Network Database"; }
public void runJob() {
// start up the network database
getContext().netDb().startup();
getContext().jobQueue().addJob(new StartAcceptingClientsJob(getContext()));
}
}

View File

@@ -0,0 +1,26 @@
package net.i2p.router.startup;
/*
* free (adj.): unencumbered; not under the control of others
* Written by jrandom in 2003 and released into the public domain
* with no warranty of any kind, either expressed or implied.
* It probably won't make your computer catch on fire, or eat
* your children, but it might. Use at your own risk.
*
*/
import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
/** start up the peer manager */
public class BootPeerManagerJob extends JobImpl {
public BootPeerManagerJob(RouterContext ctx) {
super(ctx);
}
public String getName() { return "Boot Peer Manager"; }
public void runJob() {
getContext().peerManager().startup();
}
}

View File

@@ -12,6 +12,7 @@ import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
/** start I2CP interface */
public class StartAcceptingClientsJob extends JobImpl {
private Log _log;
@@ -23,13 +24,10 @@ public class StartAcceptingClientsJob extends JobImpl {
public String getName() { return "Start Accepting Clients"; }
public void runJob() {
// start up the network database
getContext().clientManager().startup();
getContext().jobQueue().addJob(new ReadConfigJob(getContext()));
// pointless
//getContext().jobQueue().addJob(new RebuildRouterInfoJob(getContext()));
getContext().jobQueue().allowParallelOperation();
}
}