Discussion: Babel plugin to optimize javascript engine code (like v8)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- babel, eslint, javascript
- Domain
- devtools, performance, tooling
Research direction
The issue names no project files or tests; start by reviewing the Point examples and the linked hidden-class and optimization-killer references. Define whether the scope is a Babel plugin, ESLint rule, runtime instrumentation, or a combination, and treat an agreed detection or measurement plan as the done criterion.
Written by the indexing model from the issue text.
Description
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
Always instantiate your object properties in the same order so that hidden classes, and subsequently optimized code, can be shared.
Adding properties to an object after instantiation will force a hidden class change and slow down any methods that were optimized for the previous hidden class. Instead, assign all of an object’s properties in its constructor.
Code that executes the same method repeatedly will run faster than code that executes many different methods only once (due to inline caching).
We should be able to lint/add a runtime check for these?
1 function Point(x,y) {
2 this.x = x;
3 this.y = y;
4 }
5
7 var obj1 = new Point(1,2);
8
9 obj1.a = 5;
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
10 obj1.a = 5;
11 obj1.b = 10;
12
13 obj2.b = 10;
14 obj2.a = 5;
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
- Dominant language
- No language data
- Stars
- 123
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from babel/notes
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
June 10th - Meeting Openmeeting
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
🧠 Ideas/Issues dump Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
documentation low-priority templates
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
jesseray718/openroot#87 ·
-
factory-active factory-automatic task-bug-reproduction-cannot-reproduce task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·
-
in-progress proposal
Difficulty 1/5 Under an hour Newbie friendliness 88/100
uibcdf/molsyssuite#36 ·