-
Notifications
You must be signed in to change notification settings - Fork 62
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
Delay applyExpr until after elaboration #732
Delay applyExpr until after elaboration #732
Conversation
let me check this works with the LH tests too... |
Sounds good - fwiw I also ran the flux tests with this version and everything passed. |
I'm trying to rationalize the correctness of this change. I think you can delay the substitution of sort variables as long as you don't structurally match on sorts, i.e., you don't make decisions based on the structure of sorts (which may have solved variables that should be considered in the decision). Presumably, elaboration shouldn't be making decisions based on the structure of sorts in the expression being elaborated so this change sounds fine... ...except that you structurally match on sorts when printing expressions for errors. For example, I think this changes the behavior of this line
checkIteTy prints the expressions (with pending substitutions) in case of an error. However, I have the impression that this always has been wrong and errors may print expressions with sorts variables that have already been solved.
unrelated and out of curiosity: do the changes in strictness have any impact? the constructors of |
Ah ya you're right - I suppose you could use |
I think there are some bugs in |
8fea3d5
to
1a12686
Compare
Hello! Is there a description available of the problem that this contribution is addressing? I don't promise to review, but it would be helpful for future reference nonetheless. |
6710ee0
to
140ae73
Compare
I just updated the description with some details. Let me know if you have questions / if I can provide additional details. |
There are a few changes I'm hoping to implement here. There are:
applyExpr
inelab
until after all the elaboration has taken place.apply
inelab
until after all the elaboration has taken place - hoping to use union find to do this. See the PoC implementation here.State
monad for folding and replace it with theReader
monad - similar to what is implemented forCheckM
The reasons for these changes are performance hang ups when passing large queries to fixpoint. We noticed that a significant amount of time is being spent in
elab
- and we suspect it's due to the exponential nature of usingapply
andapplyExpr
. Additionally, we observed thattrans
andfold
in the type visitors and folders were taking up a massive amount of memory. By "specializing" the visitor not to have an accumulator we reduced the memory footprint on certain queries by ~ half.As of now, changes 1 and 3 are implemented and I'm working on 2. Just 1 and 3 cut down the time fixpoint takes on large queries by ~ 1/3.