You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Idea for x5 optimization for functions that return classes, objects or small arrays #997
I noticed that when we create a functions that return Class, Objects or small Array performance become worse than in JS. I was curious why this happens and created a new version of my code and get x7 boost in performance for f64 struct. It can be little bit optimistic because I have too simple structure.
The idea:
When you compile a code it often allocated objects with the same Shapes. It can be a Points, some Tuples or general Objects. All is ok when you create it once or twice in your code, but it can be huge problem when you run this code in loop.
So we can allocate only once a relatively big Turing tape with this objects. And when we invoke a function that return objects with this shapes, we can pass a new index from tape in which we can store result object.
Also we can notice that we can reuse space in this tape for different function scopes. Here a lot of room for your imagination how to do this. For example all methods in one class can have only one temporary cache and another cache for another functions.
Object explosion optimization aka scalar replacement (when simple objects represent as set of variables/registers without alloc in memory) is not yet present. Also that could be easily handle / optimize when multi-values will landed.
Btw you could improve speed even more by using global variables instead array. Replace this
changed the title [-]Idea for x3 optimization for functions that return classes, objects or small arrays[/-][+]Idea for x5 optimization for functions that return classes, objects or small arrays[/+]on Dec 9, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
MaxGraey commentedon Dec 7, 2019
Object explosion optimization aka scalar replacement (when simple objects represent as set of variables/registers without alloc in memory) is not yet present. Also that could be easily handle / optimize when multi-values will landed.
Btw you could improve speed even more by using global variables instead array. Replace this
to
MaxGraey commentedon Dec 7, 2019
Also I'm not sure you need so many variables. I guess one or two will be enough
munrocket commentedon Dec 9, 2019
Yep, you right with one variable optimization even better. Huge impact.
[-]Idea for x3 optimization for functions that return classes, objects or small arrays[/-][+]Idea for x5 optimization for functions that return classes, objects or small arrays[/+]munrocket commentedon Dec 14, 2019
This will be not acutal after Platform-independent Just-in-Time (JIT) compilation. But we don't know when it will be implemented.
stale commentedon Jan 26, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.