| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Somewhat related: perhaps we should move module.exports in each file to the bottom of the file for consistency and easier locatability? |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM and +1 for moving module.exports to the bottom of the file.
Sorry, something went wrong.
|
ok, moved module.exports to the end! |
Sorry, something went wrong.
Sorry, something went wrong.
|
Standard location for module.exports = { is at top of file, not bottom, grep 'exports = {' lib/**/*.js to see this. For good reason, IMO, when looking at a module, what it exports is among the most important information. |
Sorry, something went wrong.
|
@sam-github IMHO having it at the bottom avoids any potential issues that could arise if exporting values assigned to variables for example. |
Sorry, something went wrong.
|
I wouldn't call it "standard" by any stretch. Our style is a bit all over the map. Sometimes we use the exports.whatever = approach, other times we use module.exports = {} at the top, other places it's in the middle somewhere. Part of this is intended to put a stake in the ground with a consistent style and another part is to use the module.exports = {} pattern consistently which is more efficient on load up time and, as I understand it correctly, allows V8 to optimize more efficiently. |
Sorry, something went wrong.
|
ok not "standard", but "majority"? I personally quite dislike the "exports at bottom" style, what a module exports is the most important thing about it, it should be at the top, and js has good support for this because of its scoping rules, but I'll live with any consistent style. Given how common exports.fu = ... is in the js world, I'd hope v8 would not be applying perf penalties to code that does that. My bigger concern is the code churn and how it affects backportability, but if we can backport the refactors, I guess we'll be OK. |
Sorry, something went wrong.
|
@sam-github It can incur a performance penalty due to the addition of hidden classes every time a new property is added, but hidden classes are still faster than dictionary mode. There is a way to force an object back into "fast" mode IIRC, but it's hacky and it's better to just define the properties in a literal from the get-go. |
Sorry, something went wrong.
Switch to the more efficient module.exports = {} pattern.
|
Updated to resolve some CI failures... @sam-github, here are the results of three benchmark runs after the refactor comparing to 7.5.0. At the results show, there is a modest but real performance improvement. james@ubuntu:~/node/node$ ./node benchmark/compare.js --old node --new ./node vm > ~/vmbench
[00:01:08|% 100| 2/2 files | 60/60 runs | 4/4 configs]: Done
james@ubuntu:~/node/node$ cat ~/vmbench | Rscript benchmark/compare.R
improvement confidence p.value
vm/run-in-context.js withSigintListener=0 breakOnSigint=0 n=1 11.62 % 0.08304273
vm/run-in-context.js withSigintListener=0 breakOnSigint=1 n=1 11.60 % 0.11359883
vm/run-in-context.js withSigintListener=1 breakOnSigint=0 n=1 2.41 % 0.73765864
vm/run-in-context.js withSigintListener=1 breakOnSigint=1 n=1 -6.96 % 0.29611889
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=0 n=1 9.06 % 0.25190565
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=1 n=1 0.86 % 0.91037805
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=0 n=1 15.10 % 0.05376572
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=1 n=1 4.57 % 0.51519663
james@ubuntu:~/node/node$ ./node benchmark/compare.js --old node --new ./node vm > ~/vmbench
[00:01:08|% 100| 2/2 files | 60/60 runs | 4/4 configs]: Done
james@ubuntu:~/node/node$ cat ~/vmbench | Rscript benchmark/compare.R
improvement confidence p.value
vm/run-in-context.js withSigintListener=0 breakOnSigint=0 n=1 25.82 % *** 0.0007840776
vm/run-in-context.js withSigintListener=0 breakOnSigint=1 n=1 -6.05 % 0.2196347443
vm/run-in-context.js withSigintListener=1 breakOnSigint=0 n=1 6.36 % 0.4161236586
vm/run-in-context.js withSigintListener=1 breakOnSigint=1 n=1 3.09 % 0.6493418279
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=0 n=1 7.04 % 0.3946533283
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=1 n=1 6.09 % 0.4692360799
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=0 n=1 3.76 % 0.6699398702
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=1 n=1 10.32 % 0.2190428802
james@ubuntu:~/node/node$ rm ~/vmbench
james@ubuntu:~/node/node$ ./node benchmark/compare.js --old node --new ./node vm > ~/vmbench
[00:00:49|% 100| 2/2 files | 60/60 runs | 4/4 configs]: Done
james@ubuntu:~/node/node$ cat ~/vmbench | Rscript benchmark/compare.R
improvement confidence p.value
vm/run-in-context.js withSigintListener=0 breakOnSigint=0 n=1 8.48 % 0.05767758
vm/run-in-context.js withSigintListener=0 breakOnSigint=1 n=1 10.78 % * 0.01045460
vm/run-in-context.js withSigintListener=1 breakOnSigint=0 n=1 5.10 % 0.34595699
vm/run-in-context.js withSigintListener=1 breakOnSigint=1 n=1 11.08 % 0.05057880
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=0 n=1 3.14 % 0.60463224
vm/run-in-this-context.js withSigintListener=0 breakOnSigint=1 n=1 1.35 % 0.81451854
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=0 n=1 15.06 % * 0.01239632
vm/run-in-this-context.js withSigintListener=1 breakOnSigint=1 n=1 -6.01 % 0.18145218
|
Sorry, something went wrong.
|
Marking as semver-major because this does cause changes to the stack trace output |
Sorry, something went wrong.
Sorry, something went wrong.
|
Is the stack trace part of the API? I thought it was just the first line, the error message? If it can't be backported, vm maintainers will have some pain, but I'll let them speak for themselves on that. |
Sorry, something went wrong.
|
I’m pretty sure we have (I have?) treated change that only affect the content of stack traces as semver-patch in the past. |
Sorry, something went wrong.
|
If it doesn't have to be semver-major then ++ :-) |
Sorry, something went wrong.
|
Pulling the semver-major label back off. |
Sorry, something went wrong.
Switch to the more efficient module.exports = {} pattern.
PR-URL: #11392
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Switch to the more efficient module.exports = {} pattern.
PR-URL: #11392
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
|
needs a backport to land on v4 |
Sorry, something went wrong.
Switch to the more efficient module.exports = {} pattern.
PR-URL: #11392
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Switch to the more efficient module.exports = {} pattern.
PR-URL: #11392
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
| Back | FazBrowse Home | New Git URL |
Switch to the more efficient module.exports = {} pattern.
Checklist
Affected core subsystem(s)
vm