-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Discussion: Babel plugin to optimize javascript engine code (like v8) #9
Comments
The easiest one to add, probably in Objects that are being used like that should be replaced by a Warning for property add will either require wrapping everything in |
I'm not sure whether this makes more sense as a babel plugin or an eslint plugin. I feel like eslint might make more sense, since the best thing is probably to let the user know something that they might not know but impacts performance, and let them decide the best way to fix... Some thoughts on things that might maybe seem catchable by a linter:
|
@lelandrichardson no. 10 in there could maybe be ignored in |
Either ESLint/Babel works but I figured Babel if this is going to require some kind of runtime changes like instrumenting or transforming code in order to cover certain things. |
Also, If we could actually build this on top of flow, we could have much more insight into the signature of functions, and when they might deopt as a result... Although just writing your JS in strict flow might make it hard to write those deopts in the first place. |
I think this make more sense with an eslint plugin which emits warning. This plugin should focus on optimizations and not best practice. If we focus on v8 performmance, what about other browsers? We might emits to much warnings for optimizations accross all browsers. Aside note: it wouldn't be a surprise to me that v8 would in the future regoranize calls itself as an optimizations. Like other VM does (JVM for example). |
All of the "optimization killers" (except for hash table mode objects) should not be a problem anymore with v8 5.5 anyway. |
@Kovensky That's a good news. But there is always legacy stuff sitting around. Could this "optimization killers" also apply to other engines? |
@Kovensky is there some kind of reference to find out more about this — why is it no longer relevant? what exactly was changed and how? etc. |
I was actually considering the same thing so I'm glad I found this discussion. I've written an ESLint warning to match 'delete this.'. This is pretty specific but I think trying to apply this to a large existing code base might produce too many false positives or generally be too noisy and go against developer productivity at the cost of very small performance benefits unless you're in hot code. I'm leaning that putting this into flow might be the best option. Perhaps letting objects opt into a @Monomorphic annotation. |
@bgirard Looks interesting, could you link your repo here? As a user I wouldn't like having a ton of warning just for the sake of optimization. This should be done implicitly I think. A Babel plugins is actually a better idea IMO. @hzoo @Kovensky I think this could be a more global subject. As with Babili for minification, what about a Babel project only for engine optimizations. There are also a lot about parsing performance improvements. |
I don't have a public repo accessible but here's a gist: It just warns on I'm not sure how a babel transformation could make any useful changes statically that would have no observable side-effects. Do you have any ideas? |
@bgirard You can make a Babel transform just error with something like |
EDIT: can also be an eslint rule/plugin or a combination of both
Pardon my inexperience/lack of knowledge in all of this but wanted to get some ideas down so we can all learn!
Also ref the thread: https://twitter.com/left_pad/status/814967401276182529
Like in: http://richardartoul.github.io/jekyll/update/2015/04/26/hidden-classes.html
We should be able to lint/add a runtime check for these?
So for the above example we could make a few warnings/errors.
We could warn that a property a is being created on line 9 but the constructor starting on line 1 doesn't contain
this.a
? So it could be added there, or ask that it be not used if possible?because
have different transition paths we can warn on this kind of thing (moving it to the constructor should fix it as well?)
In some cases we can do a static check for these kinds of things but otherwise we will probably want to just do some code instrumentation around objects/etc to do runtime check/analysis instead?
Maybe we can use something like ES2015 Proxy (or just wrap certain variables in functions), or is it necessary to instrument v8 as well or use something like IRHydra?
Might be cool to see some data around the kinds of objects created (how many times) and what properties are available and added/removed at what lines in the codebase.
Other deopts; https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
cc @addyosmani, @lelandrichardson, @jordwalke
The text was updated successfully, but these errors were encountered: