Skip to content

Reuse prebuilt KMIR definition to avoid redundant llvm-kompile processes#1069

Merged
dkcumming merged 6 commits intomasterfrom
dc/single-kompile
Apr 21, 2026
Merged

Reuse prebuilt KMIR definition to avoid redundant llvm-kompile processes#1069
dkcumming merged 6 commits intomasterfrom
dc/single-kompile

Conversation

@dkcumming
Copy link
Copy Markdown
Collaborator

If a Rust file contains multiple targets to prove (e.g. verify-rust-std challenge 11) then multiple llvm-kompile processes will be invoked by _prove. This PR pushes this process earlier to create a KMIR definition with all the required start symbols so that llvm-kompile is called once per file.

In particular:

  • test_verify_rust_std now compiles a prebuilt KMIR definition with reduced start symbols. This definition is reused for all proof harnesses in a file;
  • prove_with_kmir is added as separate control-flow to prove. This may not be elegant, but right now I think it is the clearest separation, and I was hesitant to add flags or refactor too aggressively;

Results from verify-std-rust challenge 11:

  • Prior to this refactoring: 1 llvm-kompile / start-symbol = 138 llvm-kompile invocations
  • After this refactoring: 1 llvm-kompile / file = 16 llvm-kompile invocations
  • Approximately 3x increase of performance
Details

PRIOR:

real 31m16.872s
user 170m18.245s
sys 5m51.240s

real 31m36.755s
user 175m15.830s
sys 6m32.859s

AFTER:

real 10m20.730s
user 44m10.271s
sys 2m15.364s

real 10m58s
user 47m0s
sys 2m24s

real 10m40.395s
user 45m54.822s
sys 2m20.399s

real 10m38.370s
user 45m32.886s
sys 2m19.782s

`test_verify_rust_std` has multiple harnesses in the one file. Instead
of reducing / kompiling for each harness, reduce once for the set of
start symbols and kompile once for the file. This means that kompilation
is pushed earlier in the pipeline into the test runner. Performance
increase for challenge 11 has been observed at approx 3x.
Fixture is left as it provides fast fail if the defintion cannot be
built
@dkcumming dkcumming requested review from Stevengre and mariaKt April 17, 2026 18:32
Comment thread kmir/src/kmir/_prove.py
kmir: KMIR,
smir_info: SMIRInfo,
opts: ProveOpts,
) -> APRProof:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! I think it's really a good idea. But I see some redundant lines of code here compared to _prove. What do you think to make kmir as a ProveOpts so that we can separate the proof prepare and proof run process?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There is some duplication, and I did consider merging them. In the end prove is changed in the stacked PR #1071 . I would be open to discussing the design and improvements in the context of that PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GREAT!

Copy link
Copy Markdown
Collaborator

@mariaKt mariaKt left a comment

Choose a reason for hiding this comment

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

LGTM, especially since there is further refactoring to address the duplication issues.

@dkcumming dkcumming merged commit 2d70882 into master Apr 21, 2026
12 checks passed
@dkcumming dkcumming deleted the dc/single-kompile branch April 21, 2026 00:11
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.

3 participants