Improve GWT SDM debug session recompilation time by a factor of 10
One of the major features of upcoming GWT release 2.7 is incremental compilation in SDM session. Because Buck recompilation is integrated as HTTP filter on every request, this optimization is jeopardized: Buck is unaware that a SDM debug session is active. We cannot entirely skip the Buck integration in SDM debug session as the site must be initialized at least once. Pass a Java property from Eclipse launch configuration and maintain initialization map with initialized flag per user agent for the site. This improves the time by a factor of 10, ca. 2 sec. for incremental recompilation on my laptop: Compilation succeeded -- 1,822s Linking into <site>/gerrit-gwtui/com.google.gerrit.GerritGwtUI/compile-5/war/gerrit_ui; Writing extras to <site>/gerrit-gwtui/com.google.gerrit.GerritGwtUI/compile-5/extras/gerrit_ui Link succeeded Linking succeeded -- 0,190s 2,140s total -- Compile completed Change-Id: Id2cb19a675d500c04e6748216a77dbb4f26fa1ab
This commit is contained in:
committed by
David Pursehouse
parent
11c56681b0
commit
500f2c98c8
@@ -58,7 +58,7 @@ link:http://www.gwtproject.org/articles/superdevmode.html[Super Dev Mode].
|
||||
* Make sure to activate source maps feature in your browser
|
||||
* Load Gerrit page `http://localhost:8080`
|
||||
* Open developer tools, source tab
|
||||
* Click on `Dev Mode On` bookmark
|
||||
* Click on `Dev Mode On` bookmark to incrementally recompile changed files
|
||||
* Select `gerrit_ui` module to compile (the `Compile` button can also be used
|
||||
as a bookmarklet).
|
||||
* Navigate on the left to: sourcemaps/gerrit_ui folder (`Ctrl+O` key shortcut
|
||||
|
||||
@@ -578,7 +578,10 @@ public class JettyServer {
|
||||
p.deleteOnExit();
|
||||
|
||||
app.addFilter(new FilterHolder(new Filter() {
|
||||
private final boolean gwtuiRecompile =
|
||||
System.getProperty("gerrit.disable-gwtui-recompile") == null;
|
||||
private final UserAgentRule rule = new UserAgentRule();
|
||||
private final Set<String> uaInitialized = new HashSet<>();
|
||||
private String lastTarget;
|
||||
private long lastTime;
|
||||
|
||||
@@ -587,30 +590,32 @@ public class JettyServer {
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
String pkg = "gerrit-gwtui";
|
||||
String target = "ui_" + rule.select((HttpServletRequest) request);
|
||||
String rule = "//" + pkg + ":" + target;
|
||||
// TODO(davido): instead of assuming specific Buck's internal
|
||||
// target directory for gwt_binary() artifacts, ask Buck for
|
||||
// the location of user agent permutation GWT zip, e. g.:
|
||||
// $ buck targets --show_output //gerrit-gwtui:ui_safari \
|
||||
// | awk '{print $2}'
|
||||
String child = String.format("%s/__gwt_binary_%s__", pkg, target);
|
||||
File zip = new File(new File(gen, child), target + ".zip");
|
||||
if (gwtuiRecompile || !uaInitialized.contains(target)) {
|
||||
String rule = "//" + pkg + ":" + target;
|
||||
// TODO(davido): instead of assuming specific Buck's internal
|
||||
// target directory for gwt_binary() artifacts, ask Buck for
|
||||
// the location of user agent permutation GWT zip, e. g.:
|
||||
// $ buck targets --show_output //gerrit-gwtui:ui_safari \
|
||||
// | awk '{print $2}'
|
||||
String child = String.format("%s/__gwt_binary_%s__", pkg, target);
|
||||
File zip = new File(new File(gen, child), target + ".zip");
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
build(root, gen, rule);
|
||||
} catch (BuildFailureException e) {
|
||||
displayFailure(rule, e.why, (HttpServletResponse) res);
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
try {
|
||||
build(root, gen, rule);
|
||||
} catch (BuildFailureException e) {
|
||||
displayFailure(rule, e.why, (HttpServletResponse) res);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.equals(lastTarget) || lastTime != zip.lastModified()) {
|
||||
lastTarget = target;
|
||||
lastTime = zip.lastModified();
|
||||
unpack(zip, dstwar);
|
||||
if (!target.equals(lastTarget) || lastTime != zip.lastModified()) {
|
||||
lastTarget = target;
|
||||
lastTime = zip.lastModified();
|
||||
unpack(zip, dstwar);
|
||||
}
|
||||
}
|
||||
uaInitialized.add(target);
|
||||
}
|
||||
|
||||
chain.doFilter(request, res);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gerrit.gwtdebug.GerritGwtDebugLauncher"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-noprecompile -src ${resource_loc:/gerrit} -workDir ${resource_loc:/gerrit}/buck-out/gen/gerrit-gwtui com.google.gerrit.GerritGwtUI -- --console-log --show-stack-trace -d ${resource_loc:/gerrit}/../gerrit_testsite"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxPermSize=256M"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxPermSize=256M -Dgerrit.disable-gwtui-recompile=true"/>
|
||||
</launchConfiguration>
|
||||
|
||||
Reference in New Issue
Block a user