Skip to content
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

Benchmarks for bindings #138

Draft
wants to merge 340 commits into
base: lets-write-a-qi-compiler
Choose a base branch
from

Conversation

countvajhula
Copy link
Collaborator

Summary of Changes

We don't have any benchmarks making use of bindings.

Public Domain Dedication

  • In contributing, I relinquish any copyright claims on my contribution and freely release it into the public domain in the simple hope that it will provide value.

countvajhula and others added 30 commits December 14, 2023 12:53
This is the same issue as we were seeing with partial application's
use of the `curry` form in its implementation, which required that the
arguments be available at compile time. We fixed it in the same way,
by wrapping the implementation in a lambda that accepts the runtime
arguments, allowing the use of bound identifiers in the feedback
specification.
@countvajhula countvajhula changed the base branch from main to lets-write-a-qi-compiler December 18, 2023 20:27
@countvajhula
Copy link
Collaborator Author

countvajhula commented Dec 18, 2023

Any other patterns that might be useful to benchmark @benknoble ? Do we feel that bindings would have any nonlocal interactions worth benchmarking, e.g. would checking (~> sqr add1 (as v) (gen v)) tell us anything more than just (~> (as v))?

I tried this with your change to boxes and here are the results before and after:

set!

$ ./report.rkt -s as

Running local (forms) benchmarks...
as: 70 ms
...

boxes:

$ ./report.rkt -s as

Running local (forms) benchmarks...
as: 89 ms
...

Average over 5 runs:

flow.rkt> (~> (70 82 97 88 85) (-< + count) / round)
84
flow.rkt> (~> (89 94 92 85 84) (-< + count) / round)
89

They're about the same. Honestly, I'm not sure our local benchmarks might be dominated by the cost of constructing lambdas and such, so that we may not actually be seeing anything specific here about bindings.

@benknoble
Copy link
Collaborator

When you only construct the binding, you don't do anything useful... that is, the code is basically (let ([v <binding>]) (set! v <input>) (values)). So I would expect increased code size from boxes and the box-set! to dominate perf.

It might also be that the compiler output is complicated enough to defeat the Chez optimizer anyway, in which case this won't matter (I never did prove that using boxes re-enables the optimizations disabled by set!). But it might still matter at the module level.

I would be interested in a module that Chez can optimize noticeably, but where using set! creates a large slow-down by disabling optimizations, and then seeing if changing to boxes "fixes" it.

Fortunately I think if we can find a small pure optimizable function, the set! just has to be elsewhere in the module to turn off optimizations? Unfortunately, I don't know of such an example.

@countvajhula
Copy link
Collaborator Author

Fwiw I asked Bard which optimizations are turned off by use of set! and it came up with:

  • Common Subexpression Elimination (CSE)
  • Constant Folding
  • Dead Code Elimination
  • Loop Optimizations
  • Inlining

We could try coming up with an example exhibiting as many of these as possible...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants