Skip to content

Commit 7915708

Browse files
authoredDec 11, 2020
core(lantern): allow non-XHRs to depend on CPU Nodes (#11767)
1 parent 2aa9845 commit 7915708

20 files changed

+162
-149
lines changed
 

‎lighthouse-core/computed/page-dependency-graph.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,26 @@ class PageDependencyGraph {
186186
* @param {Array<CPUNode>} cpuNodes
187187
*/
188188
static linkCPUNodes(rootNode, networkNodeOutput, cpuNodes) {
189+
/** @type {Set<LH.Crdp.Network.ResourceType|undefined>} */
190+
const linkableResourceTypes = new Set([
191+
NetworkRequest.TYPES.XHR, NetworkRequest.TYPES.Fetch, NetworkRequest.TYPES.Script,
192+
]);
193+
189194
/** @param {CPUNode} cpuNode @param {string} reqId */
190195
function addDependentNetworkRequest(cpuNode, reqId) {
191196
const networkNode = networkNodeOutput.idToNodeMap.get(reqId);
192197
if (!networkNode ||
193-
// Ignore all non-XHRs
194-
networkNode.record.resourceType !== NetworkRequest.TYPES.XHR ||
195198
// Ignore all network nodes that started before this CPU task started
196199
// A network request that started earlier could not possibly have been started by this task
197200
networkNode.startTime <= cpuNode.startTime) return;
201+
const {record} = networkNode;
202+
const resourceType = record.resourceType ||
203+
record.redirectDestination && record.redirectDestination.resourceType;
204+
if (!linkableResourceTypes.has(resourceType)) {
205+
// We only link some resources to CPU nodes because we observe LCP simulation
206+
// regressions when including images, etc.
207+
return;
208+
}
198209
cpuNode.addDependent(networkNode);
199210
}
200211

‎lighthouse-core/test/audits/__snapshots__/metrics-test.js.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ Object {
5959
"cumulativeLayoutShiftAllFrames": 0,
6060
"estimatedInputLatency": 543,
6161
"estimatedInputLatencyTs": undefined,
62-
"firstCPUIdle": 3677,
62+
"firstCPUIdle": 3790,
6363
"firstCPUIdleTs": undefined,
6464
"firstContentfulPaint": 2289,
6565
"firstContentfulPaintTs": undefined,
6666
"firstMeaningfulPaint": 2758,
6767
"firstMeaningfulPaintTs": undefined,
68-
"interactive": 4462,
68+
"interactive": 4671,
6969
"interactiveTs": undefined,
7070
"largestContentfulPaint": 2758,
7171
"largestContentfulPaintAllFrames": undefined,
@@ -102,7 +102,7 @@ Object {
102102
"observedTraceEndTs": 713044439102,
103103
"speedIndex": 3681,
104104
"speedIndexTs": undefined,
105-
"totalBlockingTime": 1167,
105+
"totalBlockingTime": 1205,
106106
}
107107
`;
108108

@@ -163,15 +163,15 @@ exports[`Performance: metrics evaluates valid input correctly 1`] = `
163163
Object {
164164
"cumulativeLayoutShift": 0,
165165
"cumulativeLayoutShiftAllFrames": 0,
166-
"estimatedInputLatency": 81,
166+
"estimatedInputLatency": 78,
167167
"estimatedInputLatencyTs": undefined,
168-
"firstCPUIdle": 3351,
168+
"firstCPUIdle": 4313,
169169
"firstCPUIdleTs": undefined,
170170
"firstContentfulPaint": 1337,
171171
"firstContentfulPaintTs": undefined,
172172
"firstMeaningfulPaint": 1553,
173173
"firstMeaningfulPaintTs": undefined,
174-
"interactive": 3427,
174+
"interactive": 4348,
175175
"interactiveTs": undefined,
176176
"largestContentfulPaint": undefined,
177177
"largestContentfulPaintAllFrames": undefined,

‎lighthouse-core/test/audits/__snapshots__/predictive-perf-test.js.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ Object {
77
"optimisticFMP": 2289,
88
"optimisticLCP": 2289,
99
"optimisticSI": 1393,
10-
"optimisticTTFCPUI": 3677,
11-
"optimisticTTI": 3677,
10+
"optimisticTTFCPUI": 3790,
11+
"optimisticTTI": 3790,
1212
"pessimisticEIL": 904,
1313
"pessimisticFCP": 2289,
1414
"pessimisticFMP": 3228,
1515
"pessimisticLCP": 3228,
1616
"pessimisticSI": 3047,
17-
"pessimisticTTFCPUI": 5248,
18-
"pessimisticTTI": 5248,
17+
"pessimisticTTFCPUI": 5551,
18+
"pessimisticTTI": 5551,
1919
"roughEstimateOfEIL": 543,
2020
"roughEstimateOfFCP": 2289,
2121
"roughEstimateOfFMP": 2758,
2222
"roughEstimateOfLCP": 2758,
2323
"roughEstimateOfSI": 3681,
24-
"roughEstimateOfTTFCPUI": 3677,
25-
"roughEstimateOfTTI": 4462,
24+
"roughEstimateOfTTFCPUI": 3790,
25+
"roughEstimateOfTTI": 4671,
2626
}
2727
`;

‎lighthouse-core/test/audits/byte-efficiency/__snapshots__/byte-efficiency-audit-test.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
exports[`Byte efficiency base audit should allow overriding of computeWasteWithTTIGraph 1`] = `
44
Object {
5-
"default": 1330,
6-
"justTTI": 800,
5+
"default": 560,
6+
"justTTI": 504,
77
}
88
`;
99

10-
exports[`Byte efficiency base audit should create load simulator with the specified settings 1`] = `1330`;
10+
exports[`Byte efficiency base audit should create load simulator with the specified settings 1`] = `960`;
1111

12-
exports[`Byte efficiency base audit should create load simulator with the specified settings 2`] = `22520`;
12+
exports[`Byte efficiency base audit should create load simulator with the specified settings 2`] = `21500`;

‎lighthouse-core/test/audits/byte-efficiency/byte-efficiency-audit-test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,17 @@ describe('Byte efficiency base audit', () => {
242242
class MockAudit extends ByteEfficiencyAudit {
243243
static audit_(artifacts, records) {
244244
return {
245-
items: records.map(record => ({url: record.url, wastedBytes: record.transferSize})),
245+
items: records.map(record => ({url: record.url, wastedBytes: record.transferSize * 0.5})),
246246
headings: [],
247247
};
248248
}
249249
}
250250

251251
class MockJustTTIAudit extends MockAudit {
252252
static computeWasteWithTTIGraph(results, graph, simulator) {
253-
return ByteEfficiencyAudit.computeWasteWithTTIGraph(results, graph, simulator,
253+
// TODO: Pass in a graph that organically has a lower TTI result rather than forcing it
254+
// to be scaled down.
255+
return 0.9 * ByteEfficiencyAudit.computeWasteWithTTIGraph(results, graph, simulator,
254256
{includeLoad: false});
255257
}
256258
}

‎lighthouse-core/test/audits/dobetterweb/uses-http2-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe('Resources are fetched over http/2', () => {
4444
// make sure we flag all the rest
4545
expect(result.details.items).toHaveLength(60);
4646
// make sure we report savings
47-
expect(result.numericValue).toMatchInlineSnapshot(`1310`);
48-
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`1310`);
47+
expect(result.numericValue).toMatchInlineSnapshot(`1340`);
48+
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`1340`);
4949
// make sure we have a failing score
5050
expect(result.score).toBeLessThan(0.5);
5151
});
@@ -70,7 +70,7 @@ describe('Resources are fetched over http/2', () => {
7070
expect(urls).not.toContain(records[30].url);
7171
expect(result.details.items).toHaveLength(30);
7272
// make sure we report less savings
73-
expect(result.numericValue).toMatchInlineSnapshot(`850`);
74-
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`850`);
73+
expect(result.numericValue).toMatchInlineSnapshot(`500`);
74+
expect(result.details.overallSavingsMs).toMatchInlineSnapshot(`500`);
7575
});
7676
});

‎lighthouse-core/test/computed/metrics/__snapshots__/estimated-input-latency-test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`Metrics: EIL should compute a simulated value 1`] = `
44
Object {
5-
"optimistic": 101,
5+
"optimistic": 93,
66
"pessimistic": 101,
7-
"timing": 81,
7+
"timing": 78,
88
}
99
`;

‎lighthouse-core/test/computed/metrics/__snapshots__/first-cpu-idle-test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`FirstInteractive computed artifact: should simulate when settings specify 1`] = `
44
Object {
5-
"optimistic": 3351,
6-
"pessimistic": 3502,
7-
"timing": 3351,
5+
"optimistic": 4313,
6+
"pessimistic": 4383,
7+
"timing": 4313,
88
}
99
`;

‎lighthouse-core/test/computed/metrics/__snapshots__/interactive-test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`Metrics: TTI should compute a simulated value 1`] = `
44
Object {
5-
"optimistic": 3351,
6-
"pessimistic": 3502,
7-
"timing": 3427,
5+
"optimistic": 4313,
6+
"pessimistic": 4383,
7+
"timing": 4348,
88
}
99
`;

‎lighthouse-core/test/computed/metrics/__snapshots__/lantern-estimated-input-latency-test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`Metrics: Lantern EIL should compute a simulated value 1`] = `
44
Object {
5-
"optimistic": 101,
5+
"optimistic": 93,
66
"pessimistic": 101,
7-
"timing": 81,
7+
"timing": 78,
88
}
99
`;

‎lighthouse-core/test/computed/metrics/__snapshots__/lantern-first-cpu-idle-test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`Metrics: Lantern TTFCPUI should compute predicted value 1`] = `
44
Object {
5-
"optimistic": 3351,
6-
"pessimistic": 3502,
7-
"timing": 3351,
5+
"optimistic": 4313,
6+
"pessimistic": 4383,
7+
"timing": 4313,
88
}
99
`;

‎lighthouse-core/test/computed/metrics/__snapshots__/lantern-interactive-test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
exports[`Metrics: Lantern TTI should compute predicted value 1`] = `
44
Object {
5-
"optimistic": 3351,
6-
"pessimistic": 3502,
7-
"timing": 3427,
5+
"optimistic": 4313,
6+
"pessimistic": 4383,
7+
"timing": 4348,
88
}
99
`;
1010

‎lighthouse-core/test/computed/metrics/first-cpu-idle-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('FirstInteractive computed artifact:', () => {
6565
optimistic: Math.round(result.optimisticEstimate.timeInMs),
6666
pessimistic: Math.round(result.pessimisticEstimate.timeInMs),
6767
}).toMatchSnapshot();
68-
assert.equal(result.optimisticEstimate.nodeTimings.size, 19);
68+
assert.equal(result.optimisticEstimate.nodeTimings.size, 20);
6969
assert.equal(result.pessimisticEstimate.nodeTimings.size, 80);
7070
assert.ok(result.optimisticGraph, 'should have created optimistic graph');
7171
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');

‎lighthouse-core/test/computed/metrics/interactive-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Metrics: TTI', () => {
3838
optimistic: Math.round(result.optimisticEstimate.timeInMs),
3939
pessimistic: Math.round(result.pessimisticEstimate.timeInMs),
4040
}).toMatchSnapshot();
41-
assert.equal(result.optimisticEstimate.nodeTimings.size, 19);
41+
assert.equal(result.optimisticEstimate.nodeTimings.size, 20);
4242
assert.equal(result.pessimisticEstimate.nodeTimings.size, 80);
4343
assert.ok(result.optimisticGraph, 'should have created optimistic graph');
4444
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');

‎lighthouse-core/test/computed/metrics/lantern-first-cpu-idle-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Metrics: Lantern TTFCPUI', () => {
2323
optimistic: Math.round(result.optimisticEstimate.timeInMs),
2424
pessimistic: Math.round(result.pessimisticEstimate.timeInMs),
2525
}).toMatchSnapshot();
26-
assert.equal(result.optimisticEstimate.nodeTimings.size, 19);
26+
assert.equal(result.optimisticEstimate.nodeTimings.size, 20);
2727
assert.equal(result.pessimisticEstimate.nodeTimings.size, 80);
2828
assert.ok(result.optimisticGraph, 'should have created optimistic graph');
2929
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');

‎lighthouse-core/test/computed/metrics/lantern-interactive-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Metrics: Lantern TTI', () => {
2727
optimistic: Math.round(result.optimisticEstimate.timeInMs),
2828
pessimistic: Math.round(result.pessimisticEstimate.timeInMs),
2929
}).toMatchSnapshot();
30-
assert.equal(result.optimisticEstimate.nodeTimings.size, 19);
30+
assert.equal(result.optimisticEstimate.nodeTimings.size, 20);
3131
assert.equal(result.pessimisticEstimate.nodeTimings.size, 80);
3232
assert.ok(result.optimisticGraph, 'should have created optimistic graph');
3333
assert.ok(result.pessimisticGraph, 'should have created pessimistic graph');

‎lighthouse-core/test/computed/metrics/speed-index-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ describe('Metrics: Speed Index', () => {
6161
}).toMatchInlineSnapshot(`
6262
Object {
6363
"optimistic": 575,
64-
"pessimistic": 563,
65-
"timing": 599,
64+
"pessimistic": 633,
65+
"timing": 635,
6666
}
6767
`);
6868
});
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
22
"roughEstimateOfFCP": {
3-
"p50": 0.292391744233104,
4-
"p90": 0.501397081651661,
5-
"p95": 0.5795269168026101
3+
"p50": 0.28115015974440893,
4+
"p90": 0.49063322495742373,
5+
"p95": 0.5191288993525603
66
},
77
"roughEstimateOfFMP": {
8-
"p50": 0.30206175397060275,
8+
"p50": 0.301651376146789,
99
"p90": 0.5385564466378778,
10-
"p95": 0.6641924269472893
10+
"p95": 0.625285684604197
1111
},
1212
"roughEstimateOfSI": {
13-
"p50": 0.274947094253622,
14-
"p90": 0.701696317749276,
15-
"p95": 1.0080896079651525
13+
"p50": 0.260989010989011,
14+
"p90": 0.6901117087298304,
15+
"p95": 0.9592408214063473
1616
},
1717
"roughEstimateOfTTFCPUI": {
18-
"p50": 0.28465238303454304,
19-
"p90": 0.6509379230322955,
20-
"p95": 0.8098063599218334
18+
"p50": 0.2543563799887577,
19+
"p90": 0.6242117117117117,
20+
"p95": 0.8210511483725518
2121
},
2222
"roughEstimateOfTTI": {
23-
"p50": 0.3055258632709021,
24-
"p90": 0.6577081000373274,
23+
"p50": 0.24779470729751404,
24+
"p90": 0.6419348364220245,
2525
"p95": 0.743897672766033
2626
},
2727
"roughEstimateOfLCP": {
2828
"p50": 0.203757225433526,
29-
"p90": 0.6464365256124721,
30-
"p95": 0.8768898488120951
29+
"p90": 0.6962974535228871,
30+
"p95": 0.9262573279851898
3131
}
3232
}

‎lighthouse-core/test/fixtures/lantern-master-computed-values.json

+70-70
Large diffs are not rendered by default.

‎lighthouse-core/test/results/sample_v2.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -432,24 +432,6 @@
432432
"transferSize": 821
433433
}
434434
},
435-
"75994.10": {
436-
"request": {
437-
"url": "http://localhost:10200/dobetterweb/dbw_tester.js",
438-
"startTime": 185603.965303,
439-
"endTime": 185605.113307,
440-
"responseReceivedTime": 185605.104776,
441-
"transferSize": 1703
442-
}
443-
},
444-
"75994.11": {
445-
"request": {
446-
"url": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
447-
"startTime": 185603.96675,
448-
"endTime": 185604.557407,
449-
"responseReceivedTime": 185604.556719,
450-
"transferSize": 144
451-
}
452-
},
453435
"75994.21": {
454436
"request": {
455437
"url": "http://localhost:10200/zone.js",
@@ -476,6 +458,24 @@
476458
"responseReceivedTime": 185606.82147599998,
477459
"transferSize": 821
478460
}
461+
},
462+
"75994.10": {
463+
"request": {
464+
"url": "http://localhost:10200/dobetterweb/dbw_tester.js",
465+
"startTime": 185603.965303,
466+
"endTime": 185605.113307,
467+
"responseReceivedTime": 185605.104776,
468+
"transferSize": 1703
469+
}
470+
},
471+
"75994.11": {
472+
"request": {
473+
"url": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
474+
"startTime": 185603.96675,
475+
"endTime": 185604.557407,
476+
"responseReceivedTime": 185604.556719,
477+
"transferSize": 144
478+
}
479479
}
480480
}
481481
}

0 commit comments

Comments
 (0)
Please sign in to comment.