-
Notifications
You must be signed in to change notification settings - Fork 63
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
Strictness optimizations #132
Conversation
Float divisions out of the inner calculation.
For diagrams with a large number of transforms, this can be 5-10% faster and use slightly less memory.
(e1 <> moveOriginBy (negateV . getTotalOffset $ o1) e2) | ||
= let !negOff = negateV . getTotalOffset $ o1 | ||
e2Off = moveOriginBy negOff e2 | ||
!() = maybe () (\f -> f `seq` ()) $ appEnvelope e2Off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like black magic to me. Can you explain what this is doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds strictness to the 'Envelope' function which is the second param. to 'TotalOffset'. Specifically, it adds strictness under the Option
by grabbing the envelope function and forcing it to be evaluated (the '\f -> f seq
()' lambda).
The reason for this is that building a fingertree (to make a Path) creates a giant chain of thunks to calculate the total envelope. We don't lose anything from strictly evaluating, because the envelope will always be used eventually. There's still quite a bit of laziness under that 'f' (which would probably be highly beneficial to remove), but I'm not sure how to do so yet. I have an idea, and if it works out, this can go back to something much cleaner.
OK, makes sense, thanks. Yeah, |
Also, thanks for this fantastic work! |
These changes result in modest performance improvements and significant memory reductions for all current benchmarks (Dragon, Rotations, Poster).