mikesol / purescript-deku

A PureScript web UI framework
https://purescript-deku.surge.sh/
Apache License 2.0
123 stars 12 forks source link

Makes all interpret functions monomorphic #40

Closed mikesol closed 1 year ago

mikesol commented 1 year ago

In order to get magic do optimizations, we make all interpret functions monomorphic. The consumer of these functions still needs to make their deku tree polymorphic (via Korok) as the interpreter is unknown at that point, but once the deku tree hits the interpreter, the interpreter will be monomorphic.

MonoidMusician commented 1 year ago

Unfortunately I don't see a noticeable performance difference with this change :( Use grammar still takes ~5 seconds on Chrome, ~4 seconds on FF for the default grammar. I implemented staggered loading and the list of parsing states is the one that takes the most time to load, which makes sense since it has the most content/elements.

mikesol commented 1 year ago

Unfortunately I don't see a noticeable performance difference with this change :( Use grammar still takes ~5 seconds on Chrome, ~4 seconds on FF for the default grammar. I implemented staggered loading and the list of parsing states is the one that takes the most time to load, which makes sense since it has the most content/elements.

We're still in the window where we can revert the composability changes. If you have time, could you build the app against this commit and post the time difference to this thread (probably needs to use the old bolson)? If it's consistently faster with the previous implementation, I'd vote for reverting & keeping hacking at the composability problem on the side.

MonoidMusician commented 1 year ago

Mysterious: this morning it was ~1s Chrome without devtools, ~5s with devtools, and ~3-4s FF with or without devtools (on this monomorphize branch). Somehow Chrome was much faster all of the sudden, I don't know why.

I just downgraded and it is much faster across the board: ~0.6s Chrome without devtools, ~2 with; <1s FF.

https://github.com/MonoidMusician/blog/tree/downgrade-deku

mikesol commented 1 year ago

Ok, super helpful ans thanks for doing that work. Let's revert tomorrow, then. I can prepare the revert branches on Bolson and Deku. Perhaps I can revisit fraggle with new energy after the revert to see if it's usable.

The only downside to reverting is that some of the SSR improvements will be lost, but those can easily be recreated by consulting main pre-revert.