AndreasMadsen / async-hook

Inspect the life of handle objects in node
MIT License
36 stars 14 forks source link

Avoid trigger de-opt in v8 #14

Closed holm closed 7 years ago

holm commented 7 years ago

The Array.from(arguments causes V8 to de-opt the function with a Bad value context for arguments value. Based on https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#what-is-safe-arguments-usage I found that copying the arguments using a regular for-loop avoids the de-opt.

This might seem like a micro-optimization, but since this is hooked on process.nextTick it makes a significant difference for our use-case at least.

AndreasMadsen commented 7 years ago

Great, but by principle I won't merge optimizations without a benchmark showing a statistical significant difference. I don't have time for that immediately, but likely within the next week. You can also do it, that would be awesome.

AndreasMadsen commented 7 years ago

async-hook has now been integrated into node-core, thus this module should no longer be used.

Thanks for your contributions, but will just close this. Any issues should be posted in https://github.com/nodejs/node.