From 7b44a5f8aa006827cc44c29284550f277c36b340 Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 13:27:38 -0700 Subject: [PATCH 1/7] Add throttling to proto --- lighthouse-core/lib/proto-preprocessor.js | 4 ++-- proto/lighthouse-result.proto | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/lib/proto-preprocessor.js b/lighthouse-core/lib/proto-preprocessor.js index 62893724eb71..82994ff620cc 100644 --- a/lighthouse-core/lib/proto-preprocessor.js +++ b/lighthouse-core/lib/proto-preprocessor.js @@ -29,10 +29,10 @@ function processForProto(lhr) { // 'ignore unknown fields' in the language of conversion. if (reportJson.configSettings) { // The settings that are in both proto and LHR - const {formFactor, locale, onlyCategories, channel} = reportJson.configSettings; + const {formFactor, locale, onlyCategories, channel, throttling} = reportJson.configSettings; // @ts-expect-error - intentionally only a subset of settings. - reportJson.configSettings = {formFactor, locale, onlyCategories, channel}; + reportJson.configSettings = {formFactor, locale, onlyCategories, channel, throttling}; } // Remove runtimeError if it is NO_ERROR diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index 1df868de6d87..183ec11fbc55 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -126,7 +126,7 @@ message LighthouseResult { map category_groups = 11; // Message containing the configuration settings for the LH run - // Next field number: 6 + // Next field number: 8 message ConfigSettings { // The possible form factors an audit can be run in. // This enum served the emulated_form_factor field, but in v7, that field @@ -158,6 +158,23 @@ message LighthouseResult { // How Lighthouse was run, e.g. from the Chrome extension or from the npm // module string channel = 4; + + // Next ID: 7 + message ThrottlingSettings { + google.protobuf.Int64Value rttMs = 1; + + google.protobuf.Int64Value throughputKbps = 2; + + google.protobuf.Int64Value requestLatencyMs = 3; + + google.protobuf.Int64Value downloadThroughputKbps = 4; + + google.protobuf.Int64Value uploadThroughputKbps = 5; + + google.protobuf.Int64Value cpuSlowdownMultiplier = 6; + } + + ThrottlingSettings throttling = 7; } // The settings that were used to run this audit From f633752bf1fccf56b0bdd562ef9f06ab08dc7944 Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 14:10:16 -0700 Subject: [PATCH 2/7] Use Doublevalue for Kbps --- proto/lighthouse-result.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index 183ec11fbc55..c6f25676fb96 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -163,13 +163,13 @@ message LighthouseResult { message ThrottlingSettings { google.protobuf.Int64Value rttMs = 1; - google.protobuf.Int64Value throughputKbps = 2; + google.protobuf.DoubleValue throughputKbps = 2; - google.protobuf.Int64Value requestLatencyMs = 3; + google.protobuf.DoubleValue requestLatencyMs = 3; - google.protobuf.Int64Value downloadThroughputKbps = 4; + google.protobuf.DoubleValue downloadThroughputKbps = 4; - google.protobuf.Int64Value uploadThroughputKbps = 5; + google.protobuf.DoubleValue uploadThroughputKbps = 5; google.protobuf.Int64Value cpuSlowdownMultiplier = 6; } From b2ae1ec83576aec2f0ed186298cdbd4fb615e590 Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 14:16:04 -0700 Subject: [PATCH 3/7] Add throttling method --- proto/lighthouse-result.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index c6f25676fb96..e9c74fae8379 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -126,7 +126,7 @@ message LighthouseResult { map category_groups = 11; // Message containing the configuration settings for the LH run - // Next field number: 8 + // Next ID: 9 message ConfigSettings { // The possible form factors an audit can be run in. // This enum served the emulated_form_factor field, but in v7, that field @@ -175,6 +175,8 @@ message LighthouseResult { } ThrottlingSettings throttling = 7; + + string throttling_method = 8; } // The settings that were used to run this audit From 04e12ef0b75f686b913cc44832554066f644aefc Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 14:26:58 -0700 Subject: [PATCH 4/7] Add throttling method to preprocessor. --- lighthouse-core/lib/proto-preprocessor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/lib/proto-preprocessor.js b/lighthouse-core/lib/proto-preprocessor.js index 82994ff620cc..91300b3f4ee8 100644 --- a/lighthouse-core/lib/proto-preprocessor.js +++ b/lighthouse-core/lib/proto-preprocessor.js @@ -29,10 +29,12 @@ function processForProto(lhr) { // 'ignore unknown fields' in the language of conversion. if (reportJson.configSettings) { // The settings that are in both proto and LHR - const {formFactor, locale, onlyCategories, channel, throttling} = reportJson.configSettings; + const {formFactor, locale, onlyCategories, channel, throttling, + throttlingMethod} = reportJson.configSettings; // @ts-expect-error - intentionally only a subset of settings. - reportJson.configSettings = {formFactor, locale, onlyCategories, channel, throttling}; + reportJson.configSettings = {formFactor, + locale, onlyCategories, channel, throttling, throttlingMethod}; } // Remove runtimeError if it is NO_ERROR From 260d09e99917f92c56ce0f6dda87b1495fd2b1b8 Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 15:14:41 -0700 Subject: [PATCH 5/7] Formatting & comments. --- lighthouse-core/lib/proto-preprocessor.js | 16 +++++++++++++--- proto/lighthouse-result.proto | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/lib/proto-preprocessor.js b/lighthouse-core/lib/proto-preprocessor.js index 91300b3f4ee8..bb465c2dd1bb 100644 --- a/lighthouse-core/lib/proto-preprocessor.js +++ b/lighthouse-core/lib/proto-preprocessor.js @@ -29,12 +29,22 @@ function processForProto(lhr) { // 'ignore unknown fields' in the language of conversion. if (reportJson.configSettings) { // The settings that are in both proto and LHR - const {formFactor, locale, onlyCategories, channel, throttling, + const { + formFactor, + locale, + onlyCategories, + channel, + throttling, throttlingMethod} = reportJson.configSettings; // @ts-expect-error - intentionally only a subset of settings. - reportJson.configSettings = {formFactor, - locale, onlyCategories, channel, throttling, throttlingMethod}; + reportJson.configSettings = { + formFactor, + locale, + onlyCategories, + channel, + throttling, + throttlingMethod}; } // Remove runtimeError if it is NO_ERROR diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index e9c74fae8379..6a43a209f602 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -161,21 +161,29 @@ message LighthouseResult { // Next ID: 7 message ThrottlingSettings { + // The round trip time in milliseconds. google.protobuf.Int64Value rttMs = 1; + // The network throughput in kilobits per second. google.protobuf.DoubleValue throughputKbps = 2; + // The network request latency in milliseconds. google.protobuf.DoubleValue requestLatencyMs = 3; + // The network download throughput in kilobits per second. google.protobuf.DoubleValue downloadThroughputKbps = 4; + // The network upload throughput in kilobits per second. google.protobuf.DoubleValue uploadThroughputKbps = 5; + // The amount of slowdown applied to the cpu (1/). google.protobuf.Int64Value cpuSlowdownMultiplier = 6; } + // The throttling config settings. ThrottlingSettings throttling = 7; + // The method used to throttle the network. string throttling_method = 8; } From cd285d66098150a330a76409229de02727a0e0fe Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 15:33:38 -0700 Subject: [PATCH 6/7] Use double instead. --- proto/lighthouse-result.proto | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index 6a43a209f602..a58e8d69cbdf 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -162,22 +162,22 @@ message LighthouseResult { // Next ID: 7 message ThrottlingSettings { // The round trip time in milliseconds. - google.protobuf.Int64Value rttMs = 1; + double rttMs = 1; // The network throughput in kilobits per second. - google.protobuf.DoubleValue throughputKbps = 2; + double throughputKbps = 2; // The network request latency in milliseconds. - google.protobuf.DoubleValue requestLatencyMs = 3; + double requestLatencyMs = 3; // The network download throughput in kilobits per second. - google.protobuf.DoubleValue downloadThroughputKbps = 4; + double downloadThroughputKbps = 4; // The network upload throughput in kilobits per second. - google.protobuf.DoubleValue uploadThroughputKbps = 5; + double uploadThroughputKbps = 5; // The amount of slowdown applied to the cpu (1/). - google.protobuf.Int64Value cpuSlowdownMultiplier = 6; + double cpuSlowdownMultiplier = 6; } // The throttling config settings. From f1f7fd1dd08aa143d11448d4eecce869bcbbacec Mon Sep 17 00:00:00 2001 From: Shane Exterkamp Date: Tue, 2 Nov 2021 15:43:35 -0700 Subject: [PATCH 7/7] snake_case --- proto/lighthouse-result.proto | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proto/lighthouse-result.proto b/proto/lighthouse-result.proto index a58e8d69cbdf..63b83e95ab8a 100644 --- a/proto/lighthouse-result.proto +++ b/proto/lighthouse-result.proto @@ -162,22 +162,22 @@ message LighthouseResult { // Next ID: 7 message ThrottlingSettings { // The round trip time in milliseconds. - double rttMs = 1; + double rtt_ms = 1; // The network throughput in kilobits per second. - double throughputKbps = 2; + double throughput_kbps = 2; // The network request latency in milliseconds. - double requestLatencyMs = 3; + double request_latency_ms = 3; // The network download throughput in kilobits per second. - double downloadThroughputKbps = 4; + double download_throughput_kbps = 4; // The network upload throughput in kilobits per second. - double uploadThroughputKbps = 5; + double upload_throughput_kbps = 5; // The amount of slowdown applied to the cpu (1/). - double cpuSlowdownMultiplier = 6; + double cpu_slowdown_multiplier = 6; } // The throttling config settings.