| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc.
Sorry, something went wrong.
| 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?
Sorry, something went wrong.
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.
Sorry, something went wrong.
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.
Sorry, something went wrong.
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.
Sorry, something went wrong.
|
Maybe @bmeurer would be interested in taking a look at the use cases and perf impact here. |
Sorry, something went wrong.
|
|
||
| // This prop name (destroyed) has to be synchronized with C++ | ||
| const destroyed = { destroyed: false }; | ||
| this[destroyedSymbol] = destroyed; |
There was a problem hiding this comment.
Is moving this safe?
Sorry, something went wrong.
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.
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
@mcollina I removed it because I don't have strong feelings about it. Happy to re-introduce if @targos doesn't feel strongly about it. I ran the benchmark after my changes and results were still very similar. The main speedup here was that we create two fewer objects per microtask. |
Sorry, something went wrong.
|
Then ok. If it does not affect benchmark I’m good! |
Sorry, something went wrong.
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>
| Back | FazBrowse Home | New Git URL |
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