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

Interactive mode #914

Closed
wants to merge 10 commits into from
Closed

Interactive mode #914

wants to merge 10 commits into from

Conversation

ranjitjhala
Copy link
Contributor

Add a FLUX_CHECK_DIFF=1 mode which

  • tracks the modification time for each DefId's source file,
  • only checks those DefId that belong to source files that were modified after the last check time
  • OR (unfortunately) DefId that generated refinement errors when last checked.

@ranjitjhala
Copy link
Contributor Author

ranjitjhala commented Dec 3, 2024

@nilehmann I updated this PR with the relevant stuff for the vscode extension too.

@Samir-Rashid If you want to merge in your edits, the key bit would be to ensure that the TypeEnvTrace::new(...) generates TypeEnvBind where the loc field is a "nice" string (e.g. source-level name like x, y, z) instead of a flux-internal thing like _1, _2, _3 etc.

@ranjitjhala
Copy link
Contributor Author

(or @Samir-Rashid -- as I said, just merge in your source-map stuff in a separate PR, and we can then merge the two...)

Copy link
Member

@nilehmann nilehmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranjitjhala can you split the vscode bits into a separate PR. I have no problem merging that, but I have apprehensions about FLUX_CHECK_DIFF. I still think the extension should be the one telling flux what to check instead of flux trying to infer a diff that's simply going to be wrong.

@ranjitjhala
Copy link
Contributor Author

@nilehmann the catch with getting the extension to tell flux which file to check is that I can't think of some easy way to actually do so. The only way (?) seems to be changing the ENV variables? which seems difficult as you have to change the "override-command" for each run?

At any rate, it doesn't really matter if the diff is wrong -- to be sound, you just run without the diff mode.

@ranjitjhala
Copy link
Contributor Author

To be clear: the difficulty is just in "communicating" the relevant files to flux -- the extension already tracks the set internally.

@nilehmann
Copy link
Member

If we have an extension we don't need to rely on rust analyzer running flux.

The way I see this working is that the extension implements a command (that you can run through the command palette or with keyboard shortcut) that calls cargo flux passing the necessary context. I was thinking we can pass the file and cursor position and then flux can infer the DefId from that. How we pass the context is not that important since we have full control of the invocation, it can be env vars or command flags.

Note that this is independent from having rust analyzer run flux. We can let rust analyzer run flux and show errors and the extension calling flux to get the checker trace. In the future, we can have the extension do both, for that we would need to implement a mapping between the error format in flux and vscode.

@ranjitjhala
Copy link
Contributor Author

hmm seems a bit wasteful to run flux twice (its neat we can reuse rust-analyzer for the errors, pretty pointless to replicate it) -- but let me try it!

@nilehmann
Copy link
Member

I don't have numbers, but I've experienced measurable slowdowns just by enabling the trace dump because it is too verbose, especially if we are dumping into a file. So what's also wasteful is to dump the trace on functions that you are not going to inspect. I'm trying to remove that overhead by not dumping the trace by default. If you don't dump the trace by default and then want to inspect a function, you actually want to re-run flux to produce the trace. But we can reduce that to a single function (modulo some stuff that we do on every run like parsing, the check diff also doesn't fix this though).

The one thing that could be considerably expensive to re-run is fixpoint, especially because we don't cache negative queries and presumably you'd want to inspect functions that do not verify. The reason we don't cache negative results is that we keep some state in memory to map the tags on heads back to info that we can use to report errors. But now I'm thinking that we can also cache negative queries by hashing that state and making it part of the "input". We just need to be careful with that hash being stable across compilations because it has spans, but rustc already implements some notion of stable hashing we could reuse.

@ranjitjhala
Copy link
Contributor Author

ranjitjhala commented Dec 3, 2024 via email

@ranjitjhala ranjitjhala closed this Dec 4, 2024
@ranjitjhala
Copy link
Contributor Author

subsumed by #919 #917

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.

2 participants