-
Notifications
You must be signed in to change notification settings - Fork 381
Record build details to Java FlightRecorder, rather than SpeedTracer #10194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
df972ed
b8de7a3
e649580
ef6e8ff
672ed57
378cd32
e27b913
c86870c
1a2e160
193ede9
2af10e4
6e719be
bf2ce69
978f355
04b80f9
6101edd
5ab8ad3
161eaa0
385329e
e3c4b57
4b47173
baf06a7
8cd5eda
f82a36a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,9 +38,7 @@ | |
| import com.google.gwt.dev.cfg.ResourceLoader; | ||
| import com.google.gwt.dev.cfg.ResourceLoaders; | ||
| import com.google.gwt.dev.util.collect.HashMap; | ||
| 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 com.google.gwt.dev.util.log.perf.SimpleEvent; | ||
| import com.google.gwt.thirdparty.debugging.sourcemap.SourceMapConsumerV3; | ||
| import com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3; | ||
| import com.google.gwt.thirdparty.debugging.sourcemap.SourceMapParseException; | ||
|
|
@@ -261,99 +259,97 @@ public ArtifactSet link(TreeLogger logger, LinkerContext context, | |
| artifacts = new ArtifactSet(artifacts); | ||
| Map<Integer, String> permMap = new HashMap<Integer, String>(); | ||
|
|
||
| Event writeSymbolMapsEvent = | ||
| SpeedTracerLogger.start(CompilerEventType.WRITE_SYMBOL_MAPS); | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
| for (CompilationResult result : artifacts.find(CompilationResult.class)) { | ||
| try (SimpleEvent ignored = new SimpleEvent("Write SymbolMaps")) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extract a constant maybe.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really want to have a single big file of constants - but maybe constants for event names at the top of each class that uses simple events? |
||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
| for (CompilationResult result : artifacts.find(CompilationResult.class)) { | ||
|
|
||
| boolean makeSymbolMaps = true; | ||
| boolean makeSymbolMaps = true; | ||
|
|
||
| for (SoftPermutation perm : result.getSoftPermutations()) { | ||
| for (Entry<SelectionProperty, String> propMapEntry : perm.getPropertyMap().entrySet()) { | ||
| if (propMapEntry.getKey().getName().equals(MAKE_SYMBOL_MAPS)) { | ||
| makeSymbolMaps = Boolean.valueOf(propMapEntry.getValue()); | ||
| for (SoftPermutation perm : result.getSoftPermutations()) { | ||
| for (Entry<SelectionProperty, String> propMapEntry : perm.getPropertyMap().entrySet()) { | ||
| if (propMapEntry.getKey().getName().equals(MAKE_SYMBOL_MAPS)) { | ||
| makeSymbolMaps = Boolean.valueOf(propMapEntry.getValue()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| permMap.put(result.getPermutationId(), result.getStrongName()); | ||
| permMap.put(result.getPermutationId(), result.getStrongName()); | ||
|
|
||
| if (makeSymbolMaps) { | ||
| PrintWriter pw = new PrintWriter(out); | ||
| doWriteSymbolMap(logger, result, pw); | ||
| pw.close(); | ||
| if (makeSymbolMaps) { | ||
| PrintWriter pw = new PrintWriter(out); | ||
| doWriteSymbolMap(logger, result, pw); | ||
| pw.close(); | ||
|
|
||
| doEmitSymbolMap(logger, artifacts, result, out); | ||
| out.reset(); | ||
| doEmitSymbolMap(logger, artifacts, result, out); | ||
| out.reset(); | ||
| } | ||
| } | ||
| } | ||
| writeSymbolMapsEvent.end(); | ||
|
|
||
| Event writeSourceMapsEvent = | ||
| SpeedTracerLogger.start(CompilerEventType.WRITE_SOURCE_MAPS); | ||
| StandardLinkerContext stdContext = (StandardLinkerContext) context; | ||
| for (SourceMapArtifact se : artifacts.find(SourceMapArtifact.class)) { | ||
| // filename is permutation_id/sourceMap<fragmentNumber>.json | ||
| final String sourceMapString; | ||
| try (InputStream in = se.getContents(logger)) { | ||
| sourceMapString = new String(in.readAllBytes(), StandardCharsets.UTF_8); | ||
| } catch (IOException ex) { | ||
| logger.log(TreeLogger.ERROR, "Error reading source map from cache", ex); | ||
| throw new UnableToCompleteException(); | ||
| } | ||
| String strongName = permMap.get(se.getPermutationId()); | ||
| String partialPath = strongName + "_sourceMap" + se.getFragment() + ".json"; | ||
|
|
||
| int fragment = se.getFragment(); | ||
| ScriptFragmentEditsArtifact editArtifact = null; | ||
| for (ScriptFragmentEditsArtifact mp : artifacts.find(ScriptFragmentEditsArtifact.class)) { | ||
| if (mp.getStrongName().equals(strongName) && mp.getFragment() == fragment) { | ||
| editArtifact = mp; | ||
| artifacts.remove(editArtifact); | ||
| break; | ||
|
|
||
| try (SimpleEvent ignored = new SimpleEvent("Write SourceMaps")) { | ||
| StandardLinkerContext stdContext = (StandardLinkerContext) context; | ||
| for (SourceMapArtifact se : artifacts.find(SourceMapArtifact.class)) { | ||
| // filename is permutation_id/sourceMap<fragmentNumber>.json | ||
| final String sourceMapString; | ||
| try (InputStream in = se.getContents(logger)) { | ||
| sourceMapString = new String(in.readAllBytes(), StandardCharsets.UTF_8); | ||
| } catch (IOException ex) { | ||
| logger.log(TreeLogger.ERROR, "Error reading source map from cache", ex); | ||
| throw new UnableToCompleteException(); | ||
| } | ||
| String strongName = permMap.get(se.getPermutationId()); | ||
| String partialPath = strongName + "_sourceMap" + se.getFragment() + ".json"; | ||
|
|
||
| int fragment = se.getFragment(); | ||
| ScriptFragmentEditsArtifact editArtifact = null; | ||
| for (ScriptFragmentEditsArtifact mp : artifacts.find(ScriptFragmentEditsArtifact.class)) { | ||
| if (mp.getStrongName().equals(strongName) && mp.getFragment() == fragment) { | ||
| editArtifact = mp; | ||
| artifacts.remove(editArtifact); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| SyntheticArtifact emArt = null; | ||
| // no need to adjust source map | ||
| if (editArtifact == null) { | ||
| emArt = emitSourceMapString(logger, sourceMapString, partialPath); | ||
| } else { | ||
| SourceMapGeneratorV3 sourceMapGenerator = new SourceMapGeneratorV3(); | ||
| SyntheticArtifact emArt = null; | ||
| // no need to adjust source map | ||
| if (editArtifact == null) { | ||
| emArt = emitSourceMapString(logger, sourceMapString, partialPath); | ||
| } else { | ||
| SourceMapGeneratorV3 sourceMapGenerator = new SourceMapGeneratorV3(); | ||
|
|
||
| if (se.getSourceRoot() != null) { | ||
| // Reapply source root since mergeMapSection() will not copy it. | ||
| sourceMapGenerator.setSourceRoot(se.getSourceRoot()); | ||
| } | ||
| if (se.getSourceRoot() != null) { | ||
| // Reapply source root since mergeMapSection() will not copy it. | ||
| sourceMapGenerator.setSourceRoot(se.getSourceRoot()); | ||
| } | ||
|
|
||
| try { | ||
| int totalPrefixLines = 0; | ||
| for (ScriptFragmentEditsArtifact.EditOperation op : editArtifact.editOperations) { | ||
| if (op.getOp() == ScriptFragmentEditsArtifact.Edit.PREFIX) { | ||
| totalPrefixLines += op.getNumLines(); | ||
| try { | ||
| int totalPrefixLines = 0; | ||
| for (ScriptFragmentEditsArtifact.EditOperation op : editArtifact.editOperations) { | ||
| if (op.getOp() == ScriptFragmentEditsArtifact.Edit.PREFIX) { | ||
| totalPrefixLines += op.getNumLines(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TODO(cromwellian): apply insert and remove edits | ||
| if (stdContext.getModule().shouldEmbedSourceMapContents()) { | ||
| embedSourcesInSourceMaps(logger, stdContext, artifacts, sourceMapGenerator, | ||
| totalPrefixLines, sourceMapString, partialPath); | ||
| } else { | ||
| sourceMapGenerator.mergeMapSection(totalPrefixLines, 0, sourceMapString, | ||
| (extKey, oldVal, newVal) -> newVal); | ||
| } | ||
| // TODO(cromwellian): apply insert and remove edits | ||
| if (stdContext.getModule().shouldEmbedSourceMapContents()) { | ||
| embedSourcesInSourceMaps(logger, stdContext, artifacts, sourceMapGenerator, | ||
| totalPrefixLines, sourceMapString, partialPath); | ||
| } else { | ||
| sourceMapGenerator.mergeMapSection(totalPrefixLines, 0, sourceMapString, | ||
| (extKey, oldVal, newVal) -> newVal); | ||
| } | ||
|
|
||
| StringWriter stringWriter = new StringWriter(); | ||
| sourceMapGenerator.appendTo(stringWriter, "sourceMap"); | ||
| emArt = emitSourceMapString(logger, stringWriter.toString(), partialPath); | ||
| } catch (Exception e) { | ||
| logger.log(TreeLogger.Type.WARN, "Can't write source map " + partialPath, e); | ||
| StringWriter stringWriter = new StringWriter(); | ||
| sourceMapGenerator.appendTo(stringWriter, "sourceMap"); | ||
| emArt = emitSourceMapString(logger, stringWriter.toString(), partialPath); | ||
| } catch (Exception e) { | ||
| logger.log(TreeLogger.Type.WARN, "Can't write source map " + partialPath, e); | ||
| } | ||
| } | ||
| artifacts.add(emArt); | ||
| artifacts.remove(se); | ||
| } | ||
| artifacts.add(emArt); | ||
| artifacts.remove(se); | ||
| } | ||
| writeSourceMapsEvent.end(); | ||
| } | ||
| return artifacts; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here now it used to end the event, but now it just commit it. Is this a change in the how SpeedTracer vs JFR handling things. see my comment on SimpleEvent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short, yes. Since (as above) commit() calls end(), we get an end() automatically here - and while speedtracer has its own separate "write the buffer to disk" thread, when we call commit() we leave it to jfr to write when it wants to.