perf: add checkInterrupted to inferType cache miss path (#13258)
This PR adds a `Core.checkInterrupted` call in `checkInferTypeCache` on cache miss, allowing cancellation to be detected during large type inference traversals. Previously, `inferTypeImp` could run for >100ms without any interruption check when processing large expressions (e.g. BVDecide proof terms), making IDE cancellation unresponsive. The check is only on cache miss (actual computation), so cache hits have zero overhead. `checkInterrupted` is used instead of the heavier `checkSystem` to minimize performance impact — local benchmarks show no measurable regression on `tests/elab/5664.lean`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
acae2b44fd
commit
d3b04871f5
1 changed files with 2 additions and 0 deletions
|
|
@ -180,12 +180,14 @@ private def inferFVarType (fvarId : FVarId) : MetaM Expr := do
|
|||
|
||||
@[inline] private def checkInferTypeCache (e : Expr) (inferType : MetaM Expr) : MetaM Expr := do
|
||||
if !(← read).cacheInferType || e.hasMVar then
|
||||
Core.checkInterrupted
|
||||
inferType
|
||||
else
|
||||
let key ← mkExprConfigCacheKey e
|
||||
match (← get).cache.inferType.find? key with
|
||||
| some type => return type
|
||||
| none =>
|
||||
Core.checkInterrupted
|
||||
let type ← inferType
|
||||
unless type.hasMVar do
|
||||
modifyInferTypeCache fun c => c.insert key type
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue