Use compose-with-values instead of compose#191
Use compose-with-values instead of compose#191countvajhula wants to merge 3 commits intodrym-org:mainfrom
compose-with-values instead of compose#191Conversation
|
I have a feeling the outer Are there major cp0 output differences? |
|
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" ?) |
|
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.
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.
46ba4a6 to
bf3fab1
Compare
We found in today's meeting that an empty `let` was being added in the expansion if there are no bindings, and the presence of this `let` was enough to evade a CP0 optimization (which detects when there is a single input argument and rewrites to avoid variadic args). So we now only apply the "lifting lets" transformation in cases where there actually are bindings in use.
82e4f07 to
ee37fa0
Compare
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 existingcompositionbenchmark 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-sdkfirst, 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.)