Adds a baseTime property to top level events to help re-normalize
timestamps for multi process compiles.
Adds some more instrumentation to profile the Compiler task.
Review at http://gwt-code-reviews.appspot.com/797801
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8643 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/Link.java b/dev/core/src/com/google/gwt/dev/Link.java
index eaa6ae4..47c5d0a 100644
--- a/dev/core/src/com/google/gwt/dev/Link.java
+++ b/dev/core/src/com/google/gwt/dev/Link.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -46,6 +46,9 @@
import com.google.gwt.dev.util.arg.OptionExtraDir;
import com.google.gwt.dev.util.arg.OptionOutDir;
import com.google.gwt.dev.util.arg.OptionWarDir;
+import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
+import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
+import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
import java.io.BufferedInputStream;
import java.io.File;
@@ -244,6 +247,8 @@
}
public static void main(String[] args) {
+ boolean success = false;
+ Event linkEvent = SpeedTracerLogger.start(CompilerEventType.LINK);
/*
* NOTE: main always exits with a call to System.exit to terminate any
* non-daemon threads that were started in Generators. Typically, this is to
@@ -259,12 +264,11 @@
}
};
if (CompileTaskRunner.runWithAppropriateLogger(options, task)) {
- // Exit w/ success code.
- System.exit(0);
+ success = true;
}
}
- // Exit w/ non-success code.
- System.exit(1);
+ linkEvent.end();
+ System.exit(success ? 0 : 1);
}
/**
@@ -419,7 +423,7 @@
/**
* Add a compilation to a linker context. Also runs the shardable part of all
* linkers that support sharding.
- *
+ *
* @return the new artifacts generated by the shardable part of this link
* operation
*/
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
index fc4b521..c047a8c 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -47,7 +47,7 @@
private interface LoadStrategy {
/**
* Perform loading on the specified module.
- *
+ *
* @param logger logs the process
* @param moduleName the name of the process
* @param moduleDef a module
@@ -69,7 +69,7 @@
@SuppressWarnings("unchecked")
private static final Map<String, ModuleDef> loadedModules = new ReferenceMap(
AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
-
+
/**
* A mapping from effective to physical module names.
*/
@@ -79,7 +79,7 @@
/**
* Creates a module in memory that is not associated with a
* <code>.gwt.xml</code> file on disk.
- *
+ *
* @param logger logs the process
* @param moduleName the synthetic module to create
* @param inherits a set of modules to inherit from
@@ -108,7 +108,7 @@
/**
* Loads a new module from the class path. Equivalent to
* {@link #loadFromClassPath(logger, moduleName, false)}.
- *
+ *
* @param logger logs the process
* @param moduleName the module to load
* @return the loaded module
@@ -118,10 +118,10 @@
throws UnableToCompleteException {
return loadFromClassPath(logger, moduleName, false);
}
-
+
/**
* Loads a new module from the class path.
- *
+ *
* @param logger logs the process
* @param moduleName the module to load
* @param refresh whether to refresh the module
@@ -182,7 +182,7 @@
/**
* Constructs a {@link ModuleDefLoader} that loads a synthetic module.
- *
+ *
* @param inherits a set of modules to inherit from
*/
private ModuleDefLoader(final String[] inherits) {
@@ -201,7 +201,7 @@
/**
* Loads a new module into <code>moduleDef</code> as an included module.
- *
+ *
* @param logger Logs the process.
* @param moduleName The module to load.
* @param moduleDef The module to add the new module to.
@@ -274,7 +274,7 @@
/**
* This method loads a module.
- *
+ *
* @param logger used to log the loading process
* @param moduleName the name of the module
* @return the module returned -- cannot be null
@@ -289,11 +289,17 @@
}
ModuleDef moduleDef = new ModuleDef(moduleName);
+ Event moduleLoadEvent = SpeedTracerLogger.start(CompilerEventType.MODULE_DEF,
+ "phase", "strategy.load()");
strategy.load(logger, moduleName, moduleDef);
+ moduleLoadEvent.end();
// Do any final setup.
//
+ Event moduleNormalizeEvent = SpeedTracerLogger.start(CompilerEventType.MODULE_DEF,
+ "phase", "moduleDef.normalize()");
moduleDef.normalize(logger);
+ moduleNormalizeEvent.end();
// Add the "physical" module name: com.google.Module
loadedModules.put(moduleName, moduleDef);
diff --git a/dev/core/src/com/google/gwt/dev/util/log/speedtracer/SpeedTracerLogger.java b/dev/core/src/com/google/gwt/dev/util/log/speedtracer/SpeedTracerLogger.java
index e60a3cd..b320c65 100644
--- a/dev/core/src/com/google/gwt/dev/util/log/speedtracer/SpeedTracerLogger.java
+++ b/dev/core/src/com/google/gwt/dev/util/log/speedtracer/SpeedTracerLogger.java
@@ -327,6 +327,7 @@
private final Event shutDownSentinel = new Event();
private final long zeroTimeNanos = System.nanoTime();
+ private final long zeroTimeMilliseconds = System.currentTimeMillis();
/**
* Constructor intended for unit testing.
@@ -446,6 +447,11 @@
}
Event newEvent = new Event(parent, type, data);
+ // Add a field to the top level event in order to track the base time
+ // so we can re-normalize the data
+ if (threadPendingEvents.size() == 0) {
+ newEvent.addData("baseTime", "" + zeroTimeMilliseconds);
+ }
threadPendingEvents.push(newEvent);
return newEvent;
}