Skip to content

SSR: eliminate closure in render.js implementation #4007

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

Closed
wants to merge 6 commits into from

Conversation

HerringtonDarkholme
Copy link
Member

@HerringtonDarkholme HerringtonDarkholme commented Oct 21, 2016

I'm trying to remove closures in src/server/render.js.

Removing closures can improve runtime performance, enable easier reasoning about memory leakage, and prevent erroneous captured variable reused.

The basic idea is to pack all captured variable into a RenderContext structure. In closure based implementation, all state changes are implicitly stored by wrapping next function. In context based implementation state transitions are explicitly recorded in renderStates property.

I have ran a preliminary benchmark here by running npn run bench:ssr.
It seems closure elimination can achieve 20% performance boost.
#4002 has also been fixed in this, because contexts are separated between two render function.

@yyx990803
Copy link
Member

Wow, very impressive! This is a pretty substantial PR, so I'll take a bit more time to evaluate it, but at a glance seems very well done.

@HerringtonDarkholme
Copy link
Member Author

Thanks for quick response! Leave comments if you have suggestions, I'm happy to fix.

@yyx990803
Copy link
Member

Manually resolved and merged as 2ac581b - thanks! Very nice work.

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

Successfully merging this pull request may close these issues.

2 participants