Skip to content
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

[ComputePressure] Remove CPU frequency information. #34890

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

for (const property of ['cpuUtilizationThresholds', 'cpuSpeedThresholds']) {
for (const property of ['cpuUtilizationThresholds']) {
for (const out_of_range_value of [-1.0, 0.0, 1.0, 2.0]) {
test(t => {
const callback = () => {};

const options = {
cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5] };
cpuUtilizationThresholds: [0.5] };
options[property] = [out_of_range_value];

assert_throws_js(TypeError, () => {
Expand All @@ -21,7 +21,7 @@ for (const property of ['cpuUtilizationThresholds', 'cpuSpeedThresholds']) {
const callback = () => {};

const options = {
cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5] };
cpuUtilizationThresholds: [0.5] };
options[property] = [valid_value];

const observer = new ComputePressureObserver(callback, options);
Expand All @@ -38,7 +38,7 @@ test(t => {
assert_throws_js(TypeError, () => {
new ComputePressureObserver(
callback,
{ cpuUtilizationThresholds: [0.5, 0.5], cpuSpeedThresholds: [0.5] });
{ cpuUtilizationThresholds: [0.5, 0.5] });
});
}, 'ComputePressureObserver constructor throws when cpuUtilizationThresholds ' +
'has duplicates');
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ promise_test(async t => {

const update = await new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
Expand All @@ -16,9 +16,4 @@ promise_test(async t => {
assert_less_than_equal(update.cpuUtilization, 1.0, 'cpuUtilization range');
assert_in_array(update.cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');

assert_equals(typeof update.cpuSpeed, 'number');
assert_greater_than_equal(update.cpuSpeed, 0.0, 'cpuSpeed range');
assert_less_than_equal(update.cpuSpeed, 1.0, 'cpuUSpeed range');
assert_in_array(update.cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');
}, 'An active ComputePressureObserver calls its callback at least once');
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

const observer = new frame_window.ComputePressureObserver(
() => {},
{cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
{cpuUtilizationThresholds: [0.5]});
const iframe_DOMException = frame_window.DOMException;

iframe.remove();
Expand All @@ -40,7 +40,7 @@

const observer = new frame_window.ComputePressureObserver(
() => {},
{cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
{cpuUtilizationThresholds: [0.5]});

await observer.observe('cpu');

Expand All @@ -57,7 +57,7 @@

const observer = new frame_window.ComputePressureObserver(
() => {},
{cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
{cpuUtilizationThresholds: [0.5]});
const iframe_DOMException = frame_window.DOMException;

// await is intentionally not used here. We want to remove the iframe while
Expand All @@ -70,13 +70,12 @@
// call in the removed iframe's ComputePressureObserver.
const update = await new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
assert_in_array(update.cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(update.cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization')
}, 'Detaching frame while ComputePressureObserver.observe() settles');

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ promise_test(async t => {
const observer1_updates = [];
const observer1 = new ComputePressureObserver(
update => { observer1_updates.push(update); },
{cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
{cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer1.disconnect());
// Ensure that observer1's quantization scheme gets registered as the frame's
// scheme before observer2 starts.
Expand All @@ -17,7 +17,7 @@ promise_test(async t => {
observer2_updates.push(update);
resolve();
},
{cpuUtilizationThresholds: [0.25], cpuSpeedThresholds: [0.75]});
{cpuUtilizationThresholds: [0.25]});
t.add_cleanup(() => observer2.disconnect());
observer2.observe('cpu').catch(reject);
});
Expand All @@ -27,7 +27,7 @@ promise_test(async t => {
//
// The check below assumes that observer2.observe() completes before the
// browser dispatches any update for observer1. This assumption is highly
// likely to be true, because there shold be a 1-second delay between
// likely to be true, because there should be a 1-second delay between
// observer1.observe() and the first update that observer1 would receive.
assert_equals(
observer1_updates.length, 0,
Expand All @@ -37,8 +37,6 @@ promise_test(async t => {
assert_equals(observer2_updates.length, 1);
assert_in_array(observer2_updates[0].cpuUtilization, [0.125, 0.625],
'cpuUtilization quantization');
assert_in_array(observer2_updates[0].cpuSpeed, [0.375, 0.875],
'cpuSpeed quantization');

// Go through one more update cycle so any (incorrect) update for observer1
// makes it through the IPC queues.
Expand All @@ -52,7 +50,7 @@ promise_test(async t => {
observer3_updates.push(update);
resolve();
},
{cpuUtilizationThresholds: [0.75], cpuSpeedThresholds: [0.25]});
{cpuUtilizationThresholds: [0.75]});
t.add_cleanup(() => observer3.disconnect());
observer3.observe('cpu').catch(reject);
});
Expand All @@ -72,8 +70,5 @@ promise_test(async t => {
assert_equals(observer3_updates.length, 1);
assert_in_array(observer3_updates[0].cpuUtilization, [0.375, 0.875],
'cpuUtilization quantization');
assert_in_array(observer3_updates[0].cpuSpeed, [0.125, 0.625],
'cpuSpeed quantization');

}, 'ComputePressureObserver with a new quantization schema stops all ' +
'other active observers in the same frame');
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ promise_test(async t => {
const observer1_updates = [];
const observer1 = new ComputePressureObserver(
update => { observer1_updates.push(update); },
{cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
{cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer1.disconnect());
// Ensure that observer1's quantization scheme gets registered as the origin's
// scheme before observer2 starts.
Expand All @@ -22,7 +22,7 @@ promise_test(async t => {
observer2_updates.push(update);
resolve();
},
{cpuUtilizationThresholds: [0.25], cpuSpeedThresholds: [0.75]});
{cpuUtilizationThresholds: [0.25]});
t.add_cleanup(() => observer2.disconnect());
observer2.observe('cpu').catch(reject);
});
Expand All @@ -32,7 +32,7 @@ promise_test(async t => {
//
// The check below assumes that observer2.observe() completes before the
// browser dispatches any update for observer1. This assumption is highly
// likely to be true, because there shold be a 1-second delay between
// likely to be true, because there should be a 1-second delay between
// observer1.observe() and the first update that observer1 would receive.
assert_equals(
observer1_updates.length, 0,
Expand All @@ -42,8 +42,6 @@ promise_test(async t => {
assert_equals(observer2_updates.length, 1);
assert_in_array(observer2_updates[0].cpuUtilization, [0.125, 0.625],
'cpuUtilization quantization');
assert_in_array(observer2_updates[0].cpuSpeed, [0.375, 0.875],
'cpuSpeed quantization');

// Go through one more update cycle so any (incorrect) update for observer1
// makes it through the IPC queues.
Expand All @@ -60,7 +58,7 @@ promise_test(async t => {
observer3_updates.push(update);
resolve();
},
{cpuUtilizationThresholds: [0.75], cpuSpeedThresholds: [0.25]});
{cpuUtilizationThresholds: [0.75]});
t.add_cleanup(() => observer3.disconnect());
observer3.observe('cpu').catch(reject);
});
Expand All @@ -80,8 +78,5 @@ promise_test(async t => {
assert_equals(observer3_updates.length, 1);
assert_in_array(observer3_updates[0].cpuUtilization, [0.375, 0.875],
'cpuUtilization quantization');
assert_in_array(observer3_updates[0].cpuSpeed, [0.125, 0.625],
'cpuSpeed quantization');

}, 'ComputePressureObserver with a new quantization schema stops all ' +
'other active observers');
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ promise_test(async t => {
const observer1_updates = [];
const observer1 = new ComputePressureObserver(update => {
observer1_updates.push(update);
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer1.disconnect());
// Ensure that observer1's schema gets registered before observer2 starts.
await observer1.observe('cpu');
Expand All @@ -15,7 +15,7 @@ promise_test(async t => {
const observer2 = new ComputePressureObserver(update => {
observer2_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer2.disconnect());
observer2.observe('cpu').catch(reject);
});
Expand All @@ -28,8 +28,6 @@ promise_test(async t => {
assert_in_array(
observer2_updates[0].cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(
observer2_updates[0].cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');

// Go through one more update cycle so any (incorrect) update for observer1
// makes it through the IPC queues.
Expand All @@ -39,7 +37,7 @@ promise_test(async t => {
const observer3 = new ComputePressureObserver(update => {
observer3_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.75], cpuSpeedThresholds: [0.25]});
}, {cpuUtilizationThresholds: [0.75]});
t.add_cleanup(() => observer3.disconnect());
observer3.observe('cpu').catch(reject);
});
Expand All @@ -52,6 +50,4 @@ promise_test(async t => {
assert_in_array(
observer3_updates[0].cpuUtilization, [0.375, 0.875],
'cpuUtilization quantization');
assert_in_array(
observer3_updates[0].cpuSpeed, [0.125, 0.625], 'cpuSpeed quantization');
}, 'Stopped ComputePressureObservers do not receive updates');
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ promise_test(async t => {
const observer1_updates = [];
const observer1 = new ComputePressureObserver(update => {
observer1_updates.push(update);
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer1.disconnect());
// Ensure that observer1's schema gets registered before observer2 starts.
observer1.observe('cpu');
Expand All @@ -15,7 +15,7 @@ promise_test(async t => {
const observer2 = new ComputePressureObserver(update => {
observer2_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer2.disconnect());
observer2.observe('cpu').catch(reject);
});
Expand All @@ -28,8 +28,6 @@ promise_test(async t => {
assert_in_array(
observer2_updates[0].cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(
observer2_updates[0].cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');

// Go through one more update cycle so any (incorrect) update for observer1
// makes it through the IPC queues.
Expand All @@ -39,7 +37,7 @@ promise_test(async t => {
const observer3 = new ComputePressureObserver(update => {
observer3_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.75], cpuSpeedThresholds: [0.25]});
}, {cpuUtilizationThresholds: [0.75]});
t.add_cleanup(() => observer3.disconnect());
observer3.observe('cpu').catch(reject);
});
Expand All @@ -52,6 +50,4 @@ promise_test(async t => {
assert_in_array(
observer3_updates[0].cpuUtilization, [0.375, 0.875],
'cpuUtilization quantization');
assert_in_array(
observer3_updates[0].cpuSpeed, [0.125, 0.625], 'cpuSpeed quantization');
}, 'Stopped ComputePressureObservers do not receive updates');
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ promise_test(async t => {
const observer1_updates = [];
const observer1 = new ComputePressureObserver(update => {
observer1_updates.push(update);
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer1.disconnect());
// Ensure that observer1's schema gets registered before observer2 starts.
observer1.observe('cpu');
Expand All @@ -15,7 +15,7 @@ promise_test(async t => {
const observer2 = new ComputePressureObserver(update => {
observer2_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
}, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer2.disconnect());
observer2.observe('cpu').catch(reject);
});
Expand All @@ -28,8 +28,6 @@ promise_test(async t => {
assert_in_array(
observer2_updates[0].cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(
observer2_updates[0].cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');

// Go through one more update cycle so any (incorrect) update for observer1
// makes it through the IPC queues.
Expand All @@ -39,7 +37,7 @@ promise_test(async t => {
const observer3 = new ComputePressureObserver(update => {
observer3_updates.push(update);
resolve();
}, {cpuUtilizationThresholds: [0.75], cpuSpeedThresholds: [0.25]});
}, {cpuUtilizationThresholds: [0.75]});
t.add_cleanup(() => observer3.disconnect());
observer3.observe('cpu').catch(reject);
});
Expand All @@ -52,6 +50,4 @@ promise_test(async t => {
assert_in_array(
observer3_updates[0].cpuUtilization, [0.375, 0.875],
'cpuUtilization quantization');
assert_in_array(
observer3_updates[0].cpuSpeed, [0.125, 0.625], 'cpuSpeed quantization');
}, 'Stopped ComputePressureObservers do not receive updates');
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
promise_test(async t => {
const update1_promise = new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});

const update2_promise = new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});

const update3_promise = new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
Expand All @@ -28,7 +28,6 @@ promise_test(async t => {
for (const update of [update1, update2, update3]) {
assert_in_array(update.cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(update.cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');
}
}, 'Three ComputePressureObserver instances with the same quantization ' +
'schema receive updates');
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
promise_test(async t => {
const update1_promise = new Promise((resolve, reject) => {
const observer = new ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
Expand All @@ -15,7 +15,7 @@ promise_test(async t => {

const update2_promise = new Promise((resolve, reject) => {
const observer = new iframe2.contentWindow.ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
Expand All @@ -25,7 +25,7 @@ promise_test(async t => {

const update3_promise = new Promise((resolve, reject) => {
const observer = new iframe3.contentWindow.ComputePressureObserver(
resolve, {cpuUtilizationThresholds: [0.5], cpuSpeedThresholds: [0.5]});
resolve, {cpuUtilizationThresholds: [0.5]});
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
});
Expand All @@ -36,7 +36,6 @@ promise_test(async t => {
for (const update of [update1, update2, update3]) {
assert_in_array(update.cpuUtilization, [0.25, 0.75],
'cpuUtilization quantization');
assert_in_array(update.cpuSpeed, [0.25, 0.75], 'cpuSpeed quantization');
}
}, 'Three ComputePressureObserver instances in different iframes, but with ' +
'the same quantization schema, receive updates');
Loading