-
Notifications
You must be signed in to change notification settings - Fork 76
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
Memoize doesn't appreciably improve performance #152
Comments
I've made some progress on this, getting a ~10x speed-up with the following 'de-thunking' function, which evaluates all views and child views, returning pure markup. I'll integrate it properly into evalMarkupThunks :: ∀ e. Markup e -> Markup e
evalMarkupThunks = foldFree pushNode >>> execWriter >>> sequence_
where
pushNode :: ∀ a. MarkupM e a -> Writer (Array (Markup e)) a
pushNode (Element n children attrs handlers rest) = do
let newChildren = evalMarkupThunks children
tell [ liftF $ Element n newChildren attrs handlers unit ]
pure rest
pushNode (Content text rest) = do
tell [ liftF $ Content text unit ]
pure rest
pushNode (Empty rest) = do
tell [ liftF $ Empty unit ]
pure rest I've only just about got my head around |
This looks like a promising approach. Is it possible to integrate it into the renderer, so that memoize is no longer needed? |
In the end we abandoned the above solution, We implemented a different solution using a global cache with an explicit supplied cache key and an explicit
It works by directly co-ordinating between a custom react component and a wrapper around the view through global state (yuck!), when the wrapper knows that the react component has rendered, it returns
|
I've been experimenting with improving the render performance of my Pux app, and it seems that most of the CPU time is spent in repeated unnecessary view rendering. However, after experimenting with memoize, the performance just won't improve significantly. After poking around a while, I think I've found the culprit: the free monad. Take the following snippet:
What occurs when myView is evaluated is that expensiveViewA is evaluated, but expensiveViewB is not, because it's in a thunk in the free monad, and so only evaluated when the monad is interpreted. Therefore memoize is only caching the first calculation in every
do
statement, which results in virtually no performance improvement.Have I understood this correctly? If so, is there any way of fixing this? I've got a week to spend on this, so am happy to work on a PR if you'll offer me some guidelines.
The text was updated successfully, but these errors were encountered: