Open pd4d10 opened 3 years ago
This could be very helpful but the problem is that in some cases, primordials cause significant regressions. Until we have optimisations from V8, we cannot have a blanket implementation of primordials.
We already have some instances where we had to revert the use of primordials to deal with significant regressions. See #38248 and #38246
Maybe we can find which primoridials are good to perf. with tools by choosing subset of promoridials to refactor?
I'm also -1 on codemods for primordials (I'm ±0 in general, depending on the use-case I guess), as we've seen that they create performance issues and they shouldn't be added without some thought, and at least some benchmarking.
Maybe we can find which primoridials are good to perf. with tools by choosing subset of promoridials to refactor?
I assume that static function primordials are probably relatively safe (MathMax etc.), however others probably less so. IIRC Array methods were especially problematic, as were FunctionApply etc.
Even so, maybe even for static functions, it might be hard to see before-hand how stuff would hurt inlining (e.g. https://github.com/nodejs/node/pull/38246#discussion_r614070012) and if there's actually a good general rule for changing stuff.
We could probably at least do codemods to automate generating out code gen traces like we did with https://bugs.chromium.org/p/v8/issues/detail?id=9702&q=bound%20apply&can=1 to check for regressions rather than doing it manually and then open up any issues upstream
Hey, is this still being worked on? If not, feel-free to self-close the issue?
I noticed that there has been a lot of work to refactor the codebase, for example:
lib/internal/validators.js
: PR search resultsI guess codemod tools may help in these cases. Actually this PR https://github.com/nodejs/node/pull/38608 is finished by the codemod script here https://github.com/pd4d10/nodejs-codemod (a rough MVP version, may have some bugs)
Can't say it saves lots of time in this case, because there are not many changes. But it may be useful in the future, especially as the codebase grows.