Repository navigation
Keep the onAborted callback in an internal field of res - #1330
Conversation
|
Isn't this really just because of the UniquePersistent bug that you fixed in V8? |
|
No, the two add up. I measured this PR without the V8 fix: 91 to 80 ns comes only from one global handle less. The V8 fix alone does not help |
|
This comment:
Is so old that it dates back to when std::unique_function was the proposed name for std::move_only_function and by that time I'm pretty sure it was 8 bytes per UniquePersistent and both fit inside the short size optimized storage. The MoveOnlyFunction is just a placeholder for the std::move_only_function maybe time to drop it and go with the C++23 standard |
|
Thanks, that explains the comment. Abaut Now that #1325 is in, |
Next small part of #1300, only the onAborted change.
onAbortedmakes two global handles on every call, one for the callback and one forres, and most frameworks call it on every request.Now the callback is kept in a second internal field of
res, so there is one global handle per request instead of two. The lambda already keepsresalive, and the callback lives as long asres.Measured on Node 26 win-x64, min of 7 alternating runs:
res.onAbortedfrom 91 ns to 80 ns per call. Same behaviour on both builds: only the last callback fires,resthrows after the abort, the callback survives a gc, and 2000 of 2000resobjects are collected afterend.