[PVerifier] Improve proof speed by not generating unused procedures#934
[PVerifier] Improve proof speed by not generating unused procedures#934TheKK wants to merge 3 commits into
Conversation
Even though they're unused they still slow down the entire time of proof.
59ccde9 to
4f4b2a2
Compare
|
Here's the result of running all examples in repo and seems that we got about 10%~25% speed up. |
|
Very cool and makes sense! Is there an issue when a function appears as a dependency twice? I am not sure this is possible, but I think it would lead to multiple generations of the same function, since you are using a list to keep track of the dependencies. |
|
Nice find — the speedups are very real and consistent. Two things to consider before this is ready: 1. Federico's dedup question. In the current diff this is actually not triggerable: 2. Transitive callees — possible correctness gap. Sketch: Why the benchmarks still all pass: I checked `Tutorial/Advanced/*Verification` and none of them declare machine-scoped named `fun`s — the only `fun` declarations are top-level globals (`RandomInt`, `RandomParticipant`) which flow through `GenerateGlobalProcedures`, a separate code path. So this benchmark set never exercises machine-method → machine-method calls; the perf wins are sound but the test surface doesn't catch the issue. Suggested fix: compute the transitive call closure from the handler's direct callee — walk each function's body collecting `FunCallStmt` targets whose `Function.Owner == machine`, until fixpoint. A `HashSet` naturally handles both this and Federico's dedup point. Adding a small regression test with a machine helper that calls another helper would lock the invariant in. Minor nit while you're in there: `functionDependeicies` typo in `GenerateMain` (spelled correctly as `functionDependencies` inside `GenerateEntryHandler`). |
I found that there are unused procedures stand inside
.uclfiles generated by PVerifier backend and we get visible speed up (about 10% for Advanced/4_Paxos) in time after removing them.This speed up should be positively correlated to the number of handlers of the entire system, thus give us better experience in the iteration of proofing.
I'll add some number later and also want to make sure that I didn't miss anything about
calldependencies for entry/event_handler in.uclfiles.Please let me know if there's anything I could do better :)