[object-stats] Unpack gzipped trace files on the fly

No-try: true
Bug: v8:7266
Change-Id: I9ca2036a54c55c754cc2bb69dcca6157f88ea0fa
Reviewed-on: https://chromium-review.googlesource.com/880960
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50807}
This commit is contained in:
Michael Lippautz 2018-01-23 15:48:08 +01:00 committed by Commit Bot
parent b008859d9a
commit 546df30bfc
3 changed files with 37 additions and 17 deletions

View File

@ -6,8 +6,9 @@ maintaining internal state versus actually allocated by the user.
The tool consumes log files produced by d8 (or Chromium) by passing The tool consumes log files produced by d8 (or Chromium) by passing
`--trace-gc-object-stats` or a trace captured using Chrome's tracing `--trace-gc-object-stats` or a trace captured using Chrome's tracing
infrastructure. Chrome trace files need to be unpacked before they can infrastructure. Chrome trace files can either be processed as gzip or raw text
be used though. files.
Hosting requires a web server, e.g.: Hosting requires a web server, e.g.:

View File

@ -9,7 +9,12 @@ found in the LICENSE file. -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>V8 Heap Statistics</title> <title>V8 Heap Statistics</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.6/pako_inflate.min.js"
integrity="sha256-N1z6ddQzX83fjw8v7uSNe7/MgOmMKdwFUv1+AJMDqNM="
crossorigin="anonymous"></script>
<link rel="import" href="details-selection.html"> <link rel="import" href="details-selection.html">
<link rel="import" href="global-timeline.html"> <link rel="import" href="global-timeline.html">
@ -73,8 +78,7 @@ function globalSelectionChangedA(e) {
<a <a
href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chrome's href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chrome's
tracing infrastructure</a> collecting data for the category tracing infrastructure</a> collecting data for the category
<code>v8.gc_stats</code>. The trace file needs to be unpacked (e.g. using <code>v8.gc_stats</code>.
<code>gunzip</code>).
</li> </li>
</ul> </ul>
<p> <p>

View File

@ -50,17 +50,32 @@ class TraceFileReader extends HTMLElement {
return; return;
} }
const result = new FileReader(); const reader = new FileReader();
result.onload = (e) => {
let contents = e.target.result.split('\n'); if (file.type === 'application/gzip') {
const return_data = (e.target.result.includes('V8.GC_Objects_Stats')) ? reader.onload = (e) => {
this.createModelFromChromeTraceFile(contents) : try {
this.createModelFromV8TraceFile(contents); const textResult = pako.inflate(e.target.result, {to: 'string'});
this.updateLabel('Finished loading \'' + file.name + '\'.'); this.processRawText(file, textResult);
this.dispatchEvent(new CustomEvent( } catch (err) {
'change', {bubbles: true, composed: true, detail: return_data})); console.error(err);
}; }
result.readAsText(file); };
reader.readAsArrayBuffer(file);
} else {
reader.onload = (e) => this.processRawText(file, e.target.result);
reader.readAsText(file);
}
}
processRawText(file, result) {
let contents = result.split('\n');
const return_data = (result.includes('V8.GC_Objects_Stats')) ?
this.createModelFromChromeTraceFile(contents) :
this.createModelFromV8TraceFile(contents);
this.updateLabel('Finished loading \'' + file.name + '\'.');
this.dispatchEvent(new CustomEvent(
'change', {bubbles: true, composed: true, detail: return_data}));
} }
createOrUpdateEntryIfNeeded(data, keys, entry) { createOrUpdateEntryIfNeeded(data, keys, entry) {
@ -193,7 +208,7 @@ class TraceFileReader extends HTMLElement {
}); });
}); });
} catch (e) { } catch (e) {
console.log('Unable to parse chrome trace file.', e); console.error('Unable to parse chrome trace file.', e);
} }
this.extendAndSanitizeModel(data, keys); this.extendAndSanitizeModel(data, keys);
return data; return data;