-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reduce_func should not be obsoleted #696
Comments
I agree that inlining functions and classes can be harmful, but, if you have so many places where you don't want to inline functions, I think you're better off disabling Check out this section of the docs, or perhaps give it a try yourself. Disable You see, I obsoleted |
Hi. It's also about the performance. Once we disable
I agree this. This issue is too trivial and our usage scenario is unusual. So if I were you I will probably close this issue. Every product has its trade off, it's OK. |
I see how this is not just about byte loss. I'll see what I can do. It might be possible to piggy-back on the implementation for |
We've just ran into this issue in the Preact team. We have some functions that should not be inlined and used function w() {
for (var n; (w.__r = u.length); )
// ...
n.some(function(n) {
// ... bunch of code
t != o &&
(function n(l) {
var u, i;
if (null != (l = l.__) && null != l.__c) {
for (l.__e = l.__c.base = null, u = 0; u < l.__k.length; u++)
if (null != (i = l.__k[u]) && null != i.__e) {
l.__e = l.__c.base = i.__e;
break;
}
return n(l);
}
})(r)));
});
} EDIT: Related PR on the preactjs repo where we are trying to upgrade our build tooling preactjs/preact#2624 |
@jareguo I do not understand. Should you not include the definition of |
This has been criminally overlooked, I really need to get on with fixing this. |
@fabiosantoscode I use terser through microbundle. I have the habit of exporting all defined functions. I assume that is why I had not run into inlining behaviour so far. I just did an experiment by removing exports of internal functions and indeed some inlining does happen. I understand this is done with bundle size in mind. However, the current implementation seems to inline the function definition without inlining the function call (there is a leftover surrounding closure). If this generated code is executed only once, no problem. However, when this is inside a hot code path it is bound to cause performance problems like the ones @jareguo reported. |
Bug report or Feature request?
Feature request
Version (complete output of
terser -V
or specific git commit)4.6.13
Complete CLI command or
minify()
options usedreduce_vars: true
Sorry to submit a new issue based on #350
As isiahmeadows mentioned:
And @fabiosantoscode mentioned:
So here is the benchmark:
https://jsperf.com/reduce-function-terser/1
As you can see, inlining function will cause performance degradation. Especially when the function is used as a constructor!
Performance is critical for us, but it's unwise for us to add
/*@__NOINLINE__*/
everywhere. Can we just make it not inline by default? Thanks.The text was updated successfully, but these errors were encountered: