-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use compose-with-values
instead of compose
#191
base: deforest-all-the-things
Are you sure you want to change the base?
Use compose-with-values
instead of compose
#191
Conversation
This was suggested by @samth, @notjack and @benknoble, as a way both to make composition using `~>` more performant, and as a step towards making it interoperable with Typed Racket. Currently, although standalone benchmarking shows a > 2x improvement, our "smoke" nonlocal benchmark for composition seems to show a slight drop in performance. Reason for the discrepancy unclear.
I have a feeling the outer Are there major cp0 output differences? |
It would be nice to say something more substantial here, but I don't understand the issues yet myself. For now, it's at least useful to acknowledge this in a minimal way.
The outer cp0, I created this module:
Then I ran:
That produced a ton of output with many sections claiming to be "cp0". But I found what appeared to be the right cp0 output. When using the original
When using
That suggest anything to you? |
No, but there are some apparent differences in the way the composition is handled (see the @samth might be about to land some improvements in the compiler though. racket/racket#5182 |
I verified that cp0 for Sam's original script for the two alternatives -- i.e., compose-with-values:
call-with-values:
|
Looking again at CP0 once integrated into the compiler, it looks like this bit that composes the functions is repeated twice:
... once in the Looking at the changes in this PR, though, I don't immediately see why it should be duplicated that way. Any ideas? |
That stood out to me, too, and I wasn't clear at pointing it out. Not sure why it's happening, but a key factor is probably
("Macro magic" ?) |
|
Summary of Changes
This approach was suggested by @samth @notjack and @benknoble on Discord as an alternative to using
compose
, and which may be more compatible with Typed Racket.Below is a script for basic benchmarking written by Sam (and modified to include using
compose-with-values
). This clearly shows a greater than 2x improvement. But after integrating it into the Qi compiler (i.e., this PR), the existingcomposition
benchmark seems to show a slight degradation in performance. It's hard to tell since the number is already so low, but increasing the number of runs by an order of magnitude shows comparable or slightly worse performance as a result of the change. This seems unexpected though, and I'm more inclined to trust the standalone result, but it would be great to at least understand the reason for the discrepancy between the results.To run the Qi benchmark for "composition" (along with others --
make install-sdk
first, though, if you haven't already):The standalone benchmarking script:
Public Domain Dedication
(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)