Skip to content

perf: refactor various timestamp caches into ES6 Maps #6365

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

Merged
merged 3 commits into from
Jan 24, 2018

Conversation

quantizor
Copy link
Contributor

@quantizor quantizor commented Jan 23, 2018

What kind of change does this PR introduce?

refactoring

Did you add tests for your changes?

modified existing unit tests

If relevant, link to documentation update:

n/a

Summary

This change satisfies #6234 which desires to change the timestamp caches from plain objects to the ES6 Map type to avoid deopts, since v8 expects things to be added to Maps but objects are only fast if properties aren't added dynamically after initial assignment.

Does this PR introduce a breaking change?

I think yes if anything is downstream is using compiler.fileTimestamps or compiler.contextTimestamps.

This change satisfies webpack#6234
which desires to change the timestamp caches from plain objects to
the ES6 Map type to avoid deopts, since v8 expects things to be
added to Maps but objects are only fast if properties aren't added
dynamically after initial assignment.
@@ -68,7 +68,7 @@ describe("NodeWatchFileSystem", function() {
if(err) throw err;
filesModified.should.be.eql([fileDirect]);
dirsModified.should.be.eql([]);
Object.assign({}, fileTimestamps).should.have.property(fileDirect).have.type("number");
fileTimestamps.get(fileDirect).should.have.type("number");
Copy link
Member

Choose a reason for hiding this comment

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

Change to:

(typeof fileTimestamps.get(fileDirect)).should.be.eql("number");

The previous line would throw a TypeError.

callback();
});
}, err => {
if(err) return callback(err);
Object.keys(fileTs).forEach(key => {
fileTs[key] += this.FS_ACCURENCY;
Array.from(fileTs.keys()).forEach(key => {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this:

for(const [file, ts] of fileTs) {
  fileTs.set(file, ts + this.FS_ACCURENCY);
}

@webpack-bot
Copy link
Contributor

It looks like this Pull Request doesn't include enough test cases (based on Code Coverage analysis of the PR diff).

A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future).

@probablyup Please check if this is appliable to your PR and if you can add more test cases.

Read the test readme for details how to write test cases.

@webpack-bot
Copy link
Contributor

@probablyup Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@ooflorent Please review the new changes.

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra merged commit f2141e1 into webpack:next Jan 24, 2018
@sokra
Copy link
Member

sokra commented Jan 24, 2018

Thanks

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.

5 participants