[object-stats] Visualizer: Check histogram sums

No-try: true
Bug: v8:7266
Change-Id: I89f54feafbd4e2a6021c3bd8e339b00ed39fc3b9
Reviewed-on: https://chromium-review.googlesource.com/883883
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50865}
This commit is contained in:
Michael Lippautz 2018-01-24 20:23:03 +01:00 committed by Commit Bot
parent 8d1526b6fb
commit c3c53dbbf1

View File

@ -145,8 +145,8 @@ class TraceFileReader extends HTMLElement {
for (const gc of Object.keys(data[isolate].gcs)) {
for (const data_set_key of keys[isolate]) {
const data_set = data[isolate].gcs[gc][data_set_key];
// 1. Create a ranked instance type array that sorts instance
// types by memory size (overall).
// Create a ranked instance type array that sorts instance types by
// memory size (overall).
data_set.ranked_instance_types =
[...data_set.non_empty_instance_types].sort(function(a, b) {
if (data_set.instance_type_data[a].overall >
@ -159,6 +159,32 @@ class TraceFileReader extends HTMLElement {
}
return 0;
});
// Check that a lower bound for histogram memory does not exceed the
// overall counter.
const checkHistogram =
(type, entry, bucket_sizes, histogram, overallProperty) => {
let sum = 0;
for (let i = 1; i < entry[histogram].length; i++) {
sum += entry[histogram][i] * bucket_sizes[i - 1];
}
const overall = entry[overallProperty];
if (sum >= overall) {
console.error(
`${type}: sum('${
histogram
}') > overall (${sum} > ${overall})`);
}
};
Object.entries(data_set.instance_type_data).forEach(([
name, entry
]) => {
checkHistogram(
name, entry, data_set.bucket_sizes, 'histogram', ' overall');
checkHistogram(
name, entry, data_set.bucket_sizes, 'over_allocated_histogram',
' over_allocated');
});
}
}
}