-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Write performance #10454
Write performance #10454
Conversation
@zodern I think I'm speaking for a lot of us here when I say: thank you for all the efforts on build time improvements! I guess the times mentioned here, and in your other recent PRs, are improvements even on top of the changes already implemented in the Meteor 1.8.1 beta? |
Thanks @KoenLav. Yes, the times are all additional, though they are from a larger app so most apps will probably not see as large of an improvement. |
Saves on average ~2ms per file in one app, which adds up when there are hundreds. SRI is currently only supported for js and css files, and Meteor only uses it for the main bundles.
Avoids converting file contents to and from buffers and strings. The conversion had been done for dynamic files before minifying them, and all files after they were minified.
42c63ce
to
01f515e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just rebased to see if the tests will pass now, but otherwise this looks great!
@zodern Happy to add you as a collaborator with push/edit permissions, by the way. Just let me know if that sounds useful to you. |
@benjamn I think that would be useful, thanks. I sent you a message on the forums with a couple of questions. |
@@ -619,7 +625,9 @@ class File { | |||
hashes.push(this._inputHash); | |||
} | |||
|
|||
hashes.push(this.sri()); | |||
if (!this._skipSri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is OK. Because of this change, now effectively when _skipSri
is set, contents of the file are not part of the hash anymore.
@@ -628,7 +636,7 @@ class File { | |||
} | |||
|
|||
sri() { | |||
if (! this._sri) { | |||
if (! this._sri && !this._skipSri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong place to put this. I think if you call sri()
, sha512 should always be computed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should wrap manifestItem.sri = file.sri()
with _skipSri
check.
JS minify performance
In development, most of the time spent minifying is from converting the content of the files to and from Buffers. This was done before minifying for dynamic files to rename the function, and afterwards for all files to restore the function name. These changes have it avoid converting the contents to and from buffers where possible, and only restores the function name for dynamic files. Saves ~400ms per rebuild in a larger app.
Skip calculating SRI for assets
The current SRI standard supports css and js files, and Meteor only uses it for the main css and js bundles. These changes disable calculating the SRI hash for assets since Meteor currently doesn't use it for assets. If some packages or apps want the SRI hash for js or css assets, then two alternatives are calculating it for production, or skipping it for assets that are not js and css files. Saves ~700ms per rebuild in one app.
Skip removing source map comments if the content won't be written
Before writing a file, Meteor removes source map comments that are in the middle of the file. These changes have it skip that step when the file's contents didn't change and it is building in place. Saved 300ms during rebuilds.