Skip to content
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

Utilizing tailcall optimization #1171

Open
bradennapier opened this issue Sep 16, 2017 · 3 comments
Open

Utilizing tailcall optimization #1171

bradennapier opened this issue Sep 16, 2017 · 3 comments

Comments

@bradennapier
Copy link

bradennapier commented Sep 16, 2017

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.

image

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.

@Andarist
Copy link
Member

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

@Andarist
Copy link
Member

Andarist commented Sep 3, 2018

@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?

@bradennapier
Copy link
Author

bradennapier commented Sep 4, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants