Repository navigation
[DO NOT MERGE] Kore: prepare function equations once per module, not per request - #4165
Draft
RaoulSchaffranek wants to merge 3 commits into
Draft
RaoulSchaffranek wants to merge 3 commits into
RaoulSchaffranek wants to merge 3 commits into
Conversation
Every Kore request of the RPC server (execute, simplify, implies, get-model, and the fallbacks of kore-rpc-booster) built its simplifier with evalSimplifier, which prepares all function equations of the module (Equation.simplifyExtractedEquations) from scratch: 1-3 s per request on KEVM, Kontrol and KMIR, although the equations never change once the module is loaded. The preparation depends only on the module (sort graph, overload graph, metadata tools and the extracted equations), so makeSerializedModule now prepares them once, keeps them in SerializedModule (preparedEquations), and exec, rpcExec, search and the RPC handlers take them from there (evalSimplifierPrepared). Everything else stays per request, the memo of function results included. evalSimplifier keeps its behaviour for the other callers. A trivial simplify request on KEVM goes from 1.5-1.8 s to 0.17-0.21 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-request equation caching and serialized persistence still need maintainer validation of proof-result equivalence and retained-memory behavior under repeated module additions with representative KEVM/Kontrol/KMIR workloads.
No open issues 🎉
What changed in this PR
This experimental PR reduces repeated work in the Kore backend by preparing function equations once per loaded module and reusing them across requests, including Booster fallbacks. It remains marked do not merge, pending correctness and memory validation.
Changes:
- Store prepared equations in
SerializedModuleduring module initialization. - Reuse them in execution, search, and RPC simplification paths.
- Keep memoization per request and retain on-demand preparation for existing simplifier callers.
| File | Description |
|---|---|
kore/src/Kore/Simplify/API.hs |
Separates equation preparation from simplifier setup and adds prepared-equation entry points. |
kore/src/Kore/JsonRpc.hs |
Uses stored prepared equations in RPC handlers. |
kore/src/Kore/Exec.hs |
Stores prepared equations and reuses them for execution and search. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Do not merge. This is an experiment to measure a performance idea. It is not ready for review.
The problem
Every request that reaches Kore in the RPC server first prepares all function equations of the definition (
Equation.simplifyExtractedEquations, called fromevalSimplifier). That is about 3,600 equations for KEVM. It costs 1–3 seconds per request, even for a trivial one. The equations never change once a module is loaded, so this work is repeated for nothing.This happens on every
simplify,implies,executeandget-modelthat Kore handles, including the fallbacks from Booster.The change
makeSerializedModuleprepares the equations once, when the module is loaded (or added withadd-module), and keeps them inSerializedModule(new fieldpreparedEquations).exec,rpcExec,searchand the RPC handlers use the stored equations (newevalSimplifierPrepared) instead of preparing them again.evalSimplifierbehaves as before for its other callers.The preparation only reads the module (sort graph, overload graph, metadata tools, extracted equations). It runs in the same environment as before (no equations, no memo, no hooked symbols); only the moment changes.
First measurement
A trivial
simplify(the integer1) on the KEVM definition, five requests on each server, same machine:These numbers come from the same change applied to v0.1.155 (branch
raoul/reuse-simplifier-0.1.155). This PR is the same commit onmaster.Still to check
🤖 Generated with Claude Code