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

core(module-duplication): ignore smaller modules #11277

Merged
merged 11 commits into from
Aug 25, 2020
Merged

Conversation

connorjclark
Copy link
Collaborator

avoids situations like this:
image

which would then be shown oddly in the treemap app by highlighting just the big module, and the other modules are way too small to even see.

@connorjclark connorjclark requested a review from a team as a code owner August 17, 2020 17:17
@connorjclark connorjclark requested review from paulirish and removed request for a team August 17, 2020 17:17
*/
static _normalizeAggregatedData(sourceDataAggregated) {
// Sort by resource size.
for (const sourceData of sourceDataAggregated.values()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can move into the larger for..of entries() block. just right at the top before we start relying on the first being biggest.

}

// Delete source datas with only one value (no duplicates).
for (const [key, sourceData] of sourceDataAggregated.entries()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can move into the the above for...of entries() block.. and be done instead of the continue

static _normalizeAggregatedData(sourceDataAggregated) {
// Sort by resource size.
for (const sourceData of sourceDataAggregated.values()) {
if (sourceData.length > 1) sourceData.sort((a, b) => b.resourceSize - a.resourceSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obv not a big deal but why the need to check length before sorting?

if (sourceData.length > 1) sourceData.sort((a, b) => b.resourceSize - a.resourceSize);
}

// Remove modules smaller than 50% size of largest.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed on voice, let's threshold on bytes instead of relative size percent.

lighthouse-core/computed/module-duplication.js Outdated Show resolved Hide resolved
/**
* @param {Map<string, Array<{scriptUrl: string, resourceSize: number}>>} moduleNameToSourceData
*/
static _normalizeAggregatedData(moduleNameToSourceData) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sorting in here seems to fit semantically with a computed artifact, but the rest of it seems like opinion that we keep relegated to the audit.

so we move it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@connorjclark sez he'll do this in a followup PR.

he gave his implicit word he'd doing it in a timely manner. 😆

if (sourceData.length > 1) sourceData.sort((a, b) => b.resourceSize - a.resourceSize);
}

// Remove modules smaller than 90% size of largest.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still dont totally understand why we want to ignore all of these. seems like a very high threshold.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the comment wrong. updated.

sourceData.sort((a, b) => b.resourceSize - a.resourceSize);
}

// Remove modules smaller than 90% size of largest.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Remove modules smaller than 90% size of largest.
// Remove modules that are <= 10% of the size of the largest module instance.

lighthouse-core/computed/module-duplication.js Outdated Show resolved Hide resolved
/**
* @param {Map<string, Array<{scriptUrl: string, resourceSize: number}>>} moduleNameToSourceData
*/
static _normalizeAggregatedData(moduleNameToSourceData) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@connorjclark sez he'll do this in a followup PR.

he gave his implicit word he'd doing it in a timely manner. 😆

*/
static _normalizeAggregatedData(moduleNameToSourceData) {
// Sort by resource size.
for (const sourceData of moduleNameToSourceData.values()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants