-
-
Notifications
You must be signed in to change notification settings - Fork 102
static-contracts: improve optimizer's test for flat scs #631
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
Conversation
Two questions/comments off the top of my head:
|
|
What if you just try a simple solution and memoize the computation of recursive-kinds with a hash table? |
I'm not sure how to memoize. The commit I just pushed here adds a new function EDIT: 1/3 travis checks failed because I didn't update the contract for |
The latest commit has better performance,
EDIT: failed a test
|
What if we have a mutable field on all |
I tried a simple version of that for I'll try it again. |
This PR currently: (1) solves for the kinds of recursive contracts before optimizing and (2) shares the result with I thought about adding a mutable "kind" field to
Here's a table with compile times from the
|
What is going on with Also, can you run this with the |
Speculation: the Schml compiler hits awful non-deterministic performance in our contract generation -- I believe caused by the iteration order of free-id-tables/sets. This could be why the σ is so high for dungeon. If so, I think we should experiment with (1) using a deterministic dictionary for free ids, or (2) see if the cost of sorting the free ids is prohibitive (I worry it will be, but we should experiment and see). |
Dungeon isn't related to Schml, though, is it? |
I phrased it poorly -- I wonder if the same issue Schml is hitting in contract generation, Dungeon is also hitting. With the σ on the measurements that high, that was just my first thought of another program with highly variable contract generation times under TR. |
meta comment -- I haven't examined in great detail the most recent changes, so it may not even totally apply, and I'm not suggesting Ben should go try this now: I wonder if we just refactored our static-contract representation to keep around more relevant/useful data if this all wouldn't just be simpler to do correctly (i.e. at a static-contract's definition site, we specify how its kind is calculated and cached, etc (similar to our DSL for Reps (see |
That might be helpful as well with #633, where the issue I'm running into is wanting to go from an sc to a type so that I know what type a contract came from. |
@pnwamk I agree the (My wishlist: (1) easier to get kind of recursive scs (2) get original type (3) check whether the sc corresponds to a "real" type constructor) |
Re-ran dungeon twice more, comparing to
EDIT: nevermind these logs. We really need |
I'm still worried about that outlier. What is going on there? Also, more broadly if we can't avoid real performance hit, do we want to revert the |
I tried recompiling dungeon with
I don't think PR adds a serious performance hit, and I don't want to revert the (The original proposal here was slow because it was solving for recursive kinds twice. But that's not happening anymore.) |
I'll try again later to reproduce the outlier. Maybe if I change the |
Does the logging tell you where the performance change is? |
Oh right ... I will get back to you about that. I only made logs for dungeon on HEAD, and since none of those logs were for a 60-second compile time, I didn't read them carefully. |
I compared logs for
Looks like time spent making contracts is about the same on my laptop. Now to fix the failing unit test(s). |
Ok, so what does take more time then? |
Looks like initialization is what's slower. Everything from "Starting" to "Starting I don't think this is anything to worry about, but if you have suggestions for how I could change this PR then I can try to implement them. Attached: filtered I ran dungeon a few more times with the timing script. The results don't show the outlier, so I think it was a measurement error (weirdness with my laptop, or with the script, or with
|
There's no way these changes impacted initialization time. My guess is therefore that something else since 6.10 changed things. Can you test HEAD with and without this PR? |
Also, we need to recognize that we're very late for the release. I'll talk to @racket/release about this, but we will need to decide whether we revert the |
I'm currently installing Racket on another machine to compare 6.10.1 with TR HEAD with TR on this pull request. Just so we're on the same page, here's what I think the alternatives for the release are, in order of my preference for them:
Here are the commits to master that need to be removed to revert the
|
Startup times on master are similar --- a little slower than 6.10.1. I also ran the The outlier from dungeon happened again :( |
Can you do master vs this PR? That's the most relevant question.
Sam
…On Oct 20, 2017 6:29 PM, "Ben Greenman" ***@***.***> wrote:
Startup times on master are similar --- a little slower than 6.10.1.
logs-master.txt
<https://github.com/racket/typed-racket/files/1403488/logs-master.txt>
I also ran the tr-performance script, "master vs. 6.10.1" and "pr631 vs
6.10.1" are similar. (Note I have the wrong order of arguments to
tr-performance, so when it says "old-time" that's actually referring to
"master" or "pr631". And "new-time" is 6.10.1.)
perf-master.txt
<https://github.com/racket/typed-racket/files/1403502/perf-master.txt>
perf-pr631.txt
<https://github.com/racket/typed-racket/files/1403503/perf-pr631.txt>
The outlier from dungeon happened again :(
It happened 1 time in 10 during the first run of "pr631" just after
running 6.10.1. I was able to reproduce it once using the same order of
arguments (and the outlier is again the first run), but every other time I
run there's no outlier.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#631 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAO78_m6Mc6pG_wQGYnDQmgd8xYNsGkhks5suR69gaJpZM4P5SXK>
.
|
master bedroom? I think I know what up with |
Damn autocorrect. I mean "master vs this PR". |
Master's a little bit faster:
(I built this table from |
Great, this makes me think this is the right thing. I'll try to look at the actual code soon. |
No, I don't have a strong reason. Commit-by-commit:
(I really wish I'd squashed those last 4) |
Are we ready to go here? |
LGTM, there's nothing more I want to add |
* Add `instantiate/optimize` to the static contracts API (new function in `instantiate.rkt`) * Add optional kwd arg `#:recursive-kinds` to sc optimizer * SC optimizer uses recursive kinds to tell if a `name/sc` or `recursive-sc` will generate a flat contract * `instantiate/optimize` - solves for a recursive kinds table - calls `optimize` with the table - calls `instantiate` with the same table
This is one idea for fixing #628 .
I'm not happy about re-computing
recursive-kinds
in the optimizer,but I don't see how to tell whether a
name/sc
is flat without it,and I didn't see an easy way to share the optimizer's
recursive-kinds
withinstantiate.rkt
Improve the static contract optimizer's ability to recognize flat contracts:
name/sc
with'flat
kind is a flat contractStep 1 is repeated later in the
instantiate
pass.