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

Implement query caching #3328

Merged
merged 7 commits into from
Jun 27, 2024
Merged

Implement query caching #3328

merged 7 commits into from
Jun 27, 2024

Conversation

mtzguido
Copy link
Member

This PR introduces an internal cache of VCs that were already successfully discharged to Z3, to later avoid asking them again. This happens very often when working interactively over a file and making small edits. The way it works, roughly, is that any time before discharging a VC of shape G |= t, we first look up hash((G,t) in an RBSet, and if it's there, we report success without making the query. Otherwise we ask Z3, and if that works, we add the hash to the RBSet.

It is not meant to be bullet proof. For one, it is not handling hash collisions and second the hash is even ignoring some possibly relevant pieces (like effect definitions in the environment, they do not go into the hash).

It's also only enabled on IDE mode, the batch mode ignores it. For one it's a lot less useful there, but most importantly this means this new feature does not affect existing makefiles, CI, etc. It also has to be explicitly enabled with --query_cache.

The cache is always kept live and populated as long as F* lives. Even popping options does not clear it (which is not immediately a problem since pragmas like #push-options go into the environment and are hashed).

This feature is mostly motivated by Pulse, where we may do many small queries in program order, so this makes interactive editing of a program fragment a lot faster. For F*, it is mostly useful when there are no changes, since queries are usually monolithic.

@nikswamy
Copy link
Collaborator

This is super useful, especially for Pulse. Thanks Guido!

@mtzguido mtzguido merged commit 40d713a into FStarLang:master Jun 27, 2024
2 checks passed
@mtzguido mtzguido deleted the query_caching branch June 27, 2024 03:48
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