Skip to content

Commit

Permalink
core(tracehouse): merge tracing-processor with trace-of-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Jun 7, 2019
1 parent 7ba6776 commit ddff3d6
Show file tree
Hide file tree
Showing 17 changed files with 781 additions and 729 deletions.
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ driver.sendCommand('Security.enable');

## Understanding a Trace

`lighthouse-core/lib/tracehouse/trace-of-tab.js` and `lighthouse-core/lib/tracehouse/tracing-processor.js` provide the core transformation of a trace into more meaningful objects. Each raw trace event has a monotonically increasing timestamp in microseconds, a thread ID, a process ID, a duration in microseconds (potentially), and other applicable metadata properties such as the event type, the task name, the frame, etc. [Learn more about trace events](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview).
`lighthouse-core/lib/tracehouse/trace-processor.js` provides the core transformation of a trace into more meaningful objects. Each raw trace event has a monotonically increasing timestamp in microseconds, a thread ID, a process ID, a duration in microseconds (potentially), and other applicable metadata properties such as the event type, the task name, the frame, etc. [Learn more about trace events](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview).

### Example Trace Event
```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const makeComputedArtifact = require('../computed-artifact.js');
const ComputedMetric = require('./metric.js');
const LHError = require('../../lib/lh-error.js');
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
const LanternCumulativeLongQueuingDelay = require('./lantern-cumulative-long-queuing-delay.js');
const TimetoInteractive = require('./interactive.js');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const makeComputedArtifact = require('../computed-artifact.js');
const ComputedMetric = require('./metric.js');
const LHError = require('../../lib/lh-error.js');
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
const LanternEstimatedInputLatency = require('./lantern-estimated-input-latency.js');

const ROLLING_WINDOW_SIZE = 5000;
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/metrics/first-cpu-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const makeComputedArtifact = require('../computed-artifact.js');
const ComputedMetric = require('./metric.js');
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
const LHError = require('../../lib/lh-error.js');
const LanternFirstCPUIdle = require('./lantern-first-cpu-idle.js');

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/metrics/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ComputedMetric = require('./metric.js');
const LanternInteractive = require('./lantern-interactive.js');

const NetworkRecorder = require('../../lib/network-recorder.js');
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
const LHError = require('../../lib/lh-error.js');

const REQUIRED_QUIET_WINDOW = 5000;
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/metrics/max-potential-fid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const makeComputedArtifact = require('../computed-artifact.js');
const MetricArtifact = require('./metric.js');
const LanternMaxPotentialFID = require('./lantern-max-potential-fid.js');
const LHError = require('../../lib/lh-error.js');
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');

class MaxPotentialFID extends MetricArtifact {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/metrics/metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
const TraceOfTab = require('../trace-of-tab.js');
const NetworkRecords = require('../network-records.js');

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/page-dependency-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const makeComputedArtifact = require('./computed-artifact.js');
const NetworkNode = require('../lib/dependency-graph/network-node.js');
const CPUNode = require('../lib/dependency-graph/cpu-node.js');
const NetworkAnalyzer = require('../lib/dependency-graph/simulator/network-analyzer.js');
const TracingProcessor = require('../lib/tracehouse/tracing-processor.js');
const TracingProcessor = require('../lib/tracehouse/trace-processor.js');
const NetworkRequest = require('../lib/network-request.js');
const TraceOfTab = require('./trace-of-tab.js');
const NetworkRecords = require('./network-records.js');
Expand Down
31 changes: 29 additions & 2 deletions lighthouse-core/computed/trace-of-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@
'use strict';

const makeComputedArtifact = require('./computed-artifact.js');
const TraceOfTab_ = require('../lib/tracehouse/trace-of-tab.js');
const LHError = require('../lib/lh-error.js');
const TraceProcessor = require('../lib/tracehouse/trace-processor.js');

// TraceProcessor throws generic errors, but we'd like our special localized and code-specific LHError
// objects to be thrown instead.
class LHTraceProcessor extends TraceProcessor {
/**
* @return {Error}
*/
static createNoNavstartError() {
return new LHError(LHError.errors.NO_NAVSTART);
}

/**
* @return {Error}
*/
static createNoFirstContentfulPaintError() {
return new LHError(LHError.errors.NO_FCP);
}

/**
* @return {Error}
*/
static createNoTracingStartedError() {
return new LHError(LHError.errors.NO_TRACING_STARTED);
}
}


class TraceOfTab {
/**
Expand All @@ -16,7 +43,7 @@ class TraceOfTab {
* @return {Promise<LH.Artifacts.TraceOfTab>}
*/
static async compute_(trace) {
return TraceOfTab_.compute(trace);
return LHTraceProcessor.computeTraceOfTab(trace);
}
}

Expand Down
5 changes: 2 additions & 3 deletions lighthouse-core/lib/minify-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
* See the following files for necessary events:
* - lighthouse-core/computed/page-dependency-graph.js
* - lighthouse-core/lib/dependency-graph/cpu-node.js
* - lighthouse-core/lib/tracehouse/trace-of-tab.js
* - lighthouse-core/lib/tracehouse/tracing-processor.js
* - lighthouse-core/lib/tracehouse/trace-processor.js
*/

const TracingProcessor = require('./tracehouse/tracing-processor.js');
const TracingProcessor = require('./tracehouse/trace-processor.js');

const toplevelTaskNames = new Set([
'RunTask', // m71+
Expand Down
Loading

0 comments on commit ddff3d6

Please sign in to comment.