Cache claim parses

Open
#4,406 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
compilers, tooling

Research direction

Start in pyk/src/pyk/ktool/kprove.py at the kprove --dry-run invocation around line 265, then trace the outer parser and use_directory flow. Implement the parse-cache lookup and fallback described in the issue, including required files; done means unchanged definitions reuse cached JSON while cache misses still run the dry parse and store its result.

Written by the indexing model from the issue text.

Description

pyk

Currently, in KEVM, when we run any command involving a claim, we run kprove --dry-run ... to get the claims out of the text files. Then we check the hash of the claim to find out the proof id on disc, and load that proof if it already exists. For some large claim structures, this whole process can take ~100s, even though all we're doing is pruning a node from the proof for example, which can be done much quicker. But we need to read the claim in to know if the proof stored on disc is up-to-date or not (by parsing it and checking its hash).

We should cache parses of claims, by using the newly merged outer parser. Specifically:

  • Here is where we invoke kprove --dry-run: https://github.com/runtimeverification/k/blob/a03b705805f72b116219997993863e0051b14195/pyk/src/pyk/ktool/kprove.py#L265
  • We should first (if the use_directory exists, otherwise skip):
    • Invoke the outer parser on the selected file.
    • Read in any require ... files as well, and invoke the outer parser on them.
    • Take a hash of the outer-parsed definition.
    • Check if the given hash exists in the f{use_directory}/parse_cache (or some similar folder), and if so read in the JSON representation of the parsed definition and return that.
    • If the given hash doesn't exist in the parse cache, then actually invoke kprove --dry-run ... and store the parse in the cache.

We perhaps don't even need to do outer-parsing at this point, but we need to be able to slurp in the required files to make sure the parse cache is actually up to date, so maybe it does make sense to do outer parser, and it's pretty quick anyway.

Eventually, we want to improve the cache granularity to be able to detect "does reparsing need to happen for my claim?". If no syntax declarations changed, and only a handful of claims changed, then we only need to reparse that handful of claims.

Dominant language
Python
Stars
591
Forks
163
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from runtimeverification/k

All issues in runtimeverification/k

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.