-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Update apply-reduction-relation* to be sensitive to alpha-equivalence #102
Conversation
Also add an immutable alpha hash constructor and update hashes in the gui to use the form provided by binding-forms.rkt Fixes racket#96
I just ran the microbenchmarks in |
For reference, measurements here: https://gist.github.com/wilbowma/99bcbc4c97f2b970091b9f43754782b2 |
I pushed a fork of this branch to https://github.com/wilbowma/redex/tree/alpha-caches, which includes using an alpha hash for judgment forms. The judgment form slow downs are in fact much more significant. Some factors over 10x |
Are you measuring this slowdown on languages that have binding forms specified or on ones that don't? |
.. That's a good question. I'll have to take a look at the tests. |
Both with and without judgment forms are slower. If you look at the logs I posted in the above gist, compare the last test in |
It shouldn't be hard to avoid the overhead for judgment forms that are on
languages without binding forms. (Just check and use a regular hash.)
For the others, well, I am not sure there is an easy solution.
Robby
…On Sat, May 27, 2017 at 11:08 AM William J. Bowman ***@***.***> wrote:
Both with and without judgment forms are slower. If you look at the logs I
posted in the above gist, compare the last test in baseline.log and
judgment-cache.log. complex-ho is run in both stlc+lists with and without
binding forms. Both are significantly slower.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#102 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAYWsAjnwZgfMJw3ty3Mcx6mYo7ifcXhks5r-Ep6gaJpZM4Nm7YZ>
.
|
Eek. I was hoping this would help performance. I've got some pathological cases where variables get freshened tens of thousands of times, and they seem to defeat the cache. |
Performance bottlenecks in redex can be hard to spot. I can take a look (no
today sadly) if you supply some code that seems unreasonably slow.
Robby
…On Sat, May 27, 2017 at 11:22 AM William J. Bowman ***@***.***> wrote:
Eek. I was hoping this would *help* performance. I've got some
pathological cases where variables get freshened tens of thousands of
times, and they seem to defeat the cache.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#102 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAYWsOkhigISrBAPSnUrE86_DK0Sg2-Cks5r-E3ggaJpZM4Nm7YZ>
.
|
I'll try to get you some code later. Will my CIC model do? I know I can reproduce the behavior there, but it's awfully complex. |
Yes that is fine.
Robby
…On Sat, May 27, 2017 at 11:59 AM William J. Bowman ***@***.***> wrote:
I'll try to get you some code later. Will my CIC model do? I know I can
reproduce the behavior there, but it's awfully complex.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#102 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAYWsNdoa6JaMMtlP8AfjHgaBO594hfgks5r-FZmgaJpZM4Nm7YZ>
.
|
I'm going to move this discussion to a separate PR. I tested @howell's PR against my extensive development and do get performance improvements (nearly 2x!). Maybe my changes to judgments are broken. |
@howell, looking over this PR, it appears that some caches are still hashes. E.g., line 1708 in reduction-semantics.rkt, and line 1719 |
Looks like those are the metafunction caches, and performance dies similar to judgment forms when I change them. |
@@ -137,6 +137,11 @@ to traverse the whole value at once, rather than one binding form at a time. | |||
(λ (x) (α-equal-hash-code language-bf-table match-pattern x)) | |||
(λ (x) (α-equal-secondary-hash-code language-bf-table match-pattern x)))) | |||
|
|||
(define (make-immutable-α-hash language-bf-table match-pattern) |
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.
As the make-*-custom-hash
interface is deprecated, perhaps this is a good time to redefine these using define-custom-hash-types
.
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.
Ah, I missed that these were deprecated.
The define-custom-hash-types
interface is a bit awkward for this use case. The functions for computing equality and hashing need to close over the language binding table and match pattern, which aren't provided until we actually make a hash. So the result would look like
(define (make-α-hash language-bf-table match-pattern)
(define-custom-hash-types this-lang-α-hash
(λ (x y) (α-equal? language-bf-table match-pattern x y))
(λ (x) (α-equal-hash-code language-bf-table match-pattern x))
(λ (x) (α-equal-secondary-hash-code language-bf-table match-pattern x)))
(make-mutable-this-lang-α-hash))
It's a bit awkward, but maybe still better than using a deprecated version?
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.
Except it will be worse, since define-custom-hash-types
defines 7 names. You need to abstract all 7 definitions over the bf-table
and match-pattern
.. it's a bit gross.
Makes me want a macro that is like splicing-let
, but instead of splicing in definitions, it .. splices in additional arguments? Essentially, allows eta expanding a bunch of definitions with respect to a set of arguments ..?
(splicing-lambda (x y)
(define-values (f g h) (values (lambda (z) x) (lambda (z) y) (lambda (z) z))))
(check-equal? (f 1 2 3) 1)
(check-equal? (g 1 2 3) 2)
(check-equal? (h 1 2 3) 3)
|
(By the way, the bug I found suggests there are no tests for |
In
|
Rereading the conversation I'm not really clear what is going on here. Looking at the commit diff, it seems like the changes are good ones, however, so I'll go ahead and merge it. If there is something else that needs doing, please let me know. |
Well, the early conversion was a bit of topic and moved to #103. |
That part seems to already be in redex. I'll work thru the diff and push what was clearly intended. |
Thanks for bringing this back to my attention. I took the liberty of putting your name on the revised commit, @howell . |
Huzzah! Thanks! |
Also add an immutable alpha hash constructor and update hashes in
the gui to use the form provided by binding-forms.rkt
Fixes #96