Uh oh!
There was an error while loading. Please reload this page.
process: improve queueMicrotask performance - #28093
Conversation
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Jun 6, 2019
| asyncResource.callback = callback; | ||
| enqueueMicrotask(FunctionPrototype.bind(runMicrotask, asyncResource)); | ||
| enqueueMicrotask(FunctionPrototypeBind(runMicrotask, asyncResource)); |
There was a problem hiding this comment.
Same question here.
Are we actually doing something wrong with the primordials so that V8 doesn't know that the properties never change?
There was a problem hiding this comment.
Not sure. @mcollina flagged this for me and I've noticed it's definitely slower. He might have more insights — not sure if he talked to the V8 team about it at all.
There was a problem hiding this comment.
There is an ongoing effort to optimize frozen object performance, see https://bugs.chromium.org/p/v8/issues/detail?id=6831 and https://bugs.chromium.org/p/v8/issues/detail?id=8538 we may revisit this when the patches upstream land here.
There was a problem hiding this comment.
Are we actually doing something wrong with the primordials so that V8 doesn't know that the properties never change?
We are. Essentially accessing them is slower than accessing normal objects. We should look on not reading properties in hot code path, but maybe only once when the module is loaded.
joyeecheung
commented
Jun 6, 2019
Maybe @bmeurer would be interested in taking a look at the use cases and perf impact here. |
| // This prop name (destroyed) has to be synchronized with C++ | ||
| const destroyed = { destroyed: false }; | ||
| this[destroyedSymbol] = destroyed; |
There was a problem hiding this comment.
Yeah. This is only needed for the case where requireManualDestroy = false. We pass it on directly to C++ in registerDestroyHook.
mcollina
commented
Jun 8, 2019
@apapirovski Can you please reintroduce the fix for the frozen primordials? I don't understand the reasoning behind removing it. You might want to re-run the benchmarks before landing. |
apapirovski
commented
Jun 8, 2019
mcollina
commented
Jun 8, 2019
Then ok. If it does not affect benchmark I’m good! |
apapirovski
commented
Jun 10, 2019
Landed in cde3928 |
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc. PR-URL: nodejs#28093 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc. PR-URL: #28093 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc.
Benchmark: https://ci.nodejs.org/job/benchmark-node-micro-benchmarks/389/
That said, this is what I get locally so I figure the system makes a difference:
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes