Open bradennapier opened 7 years ago
Huh, so Safari has tail call optimization already? Nice!
The concern i have - doesnt it make debugging harder though? Since it omit stack frames it might be, well, trace the stack and origin of the call.
Anyway - this is for sure a thing to look into
@bradennapier just going through issues, totally forgot about this one, is it even possible to gain anything here from TCO? what i mean - isnt TCO in javascript applicable only for a "single-depth" calls? like when A calls A which calls A etc? does it work through layers of functions like in the given example?
If JavaScript has proper TCO it would resolve the issue as it removes the current frame from the stack entirely, as long as you continually use them and know when and how they should be used you’d be able to remove unwanted frames like we need here.
My experience with true tailcall optimization lies within Tcl. Definitely a huge benefit in cases like this.
In my case it became enough i actually rewrote redux AND redux saga into what I would consider far more sane for performance-critical applications. :)
I do really hope to see Js world take a more prioritized stance on TCO though!
However, I don't think it would work on generators anyway.
Taking a super quick look at the source code, it woudl appear that tailcall optimization is not really utilized at all within the source for redux-saga.
I havent studied tailcall optimization like I have for other langauges - butI do know the stack traces within redux-saga are essentially useless because they are packed full of proc.js calls. Tailcall optimization should fix this.
While it isnt technically implemented in chrome yet - it should work within safari. I dont have a situation to test right now but it should be a super simple change to utilize it since redux-saga is already built in a way that subsequent calls are rarely affected by the state of the previous calls.
https://github.com/Dash-OS/redux-saga -- this was a super crude and quick attempt at doing this.