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

DO NOT MERGE: eagerly stringifying tags when applied, rather than storing them up and stringifying on .render #166

Closed
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@lihaoyi
Copy link
Owner

lihaoyi commented Jun 16, 2017

  • Status quo, constructing a HTML fragment builds up a big list of Modifiers, which is then taken apart to build a Builder object, which is then taken apart to fill a StringBuilder

  • After the first three commits up to 7dc316a, constructing a HTML fragment a Builder object, which is then taken apart to fill a StringBuilder

  • After all commits in this PR, constructing a HTML fragment directly fills a StringBuilder

This makes Frags and Tags no longer immutable. They never really were, especially in JsDom land where they could contain arbitrary mutable DOM elements, but this would make it official. With this diff, you should no longer assign Frags or Tags to vals: they should be defs and re-computed each time.

text.Builder is now just a StringBuilder, and any Frags that get passed into a Tag get immediately flattened into that StringBuilder

This should build-up/tear-down fewer intermediate data-structures and result in less garbage/memory usage, but somehow still seems to be giving me a 10-20% slowdown rather than a speed-up. Notably, going "halfway" (commit 7dc316a) to make Frags directly affect the Builder but not get immediately flattened, seems to give about a 20% speedup. I've poked around with JProfiler and haven't figured out why putting things into a StringBuilder earlier rather than later is resulting in such a huge slowdown

@lihaoyi lihaoyi changed the title Experimental: eagerly stringifying tags when applied, rather than storing them up and stringifying on .render DO NOT MERGE: eagerly stringifying tags when applied, rather than storing them up and stringifying on .render Jun 16, 2017

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