-
Notifications
You must be signed in to change notification settings - Fork 131
fix: add missing initHeartbeats
#1037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Mathlib CI status (docs):
|
|
LGTM Could you explain, for documentation purposes, why this isn't something Lean core could do? |
|
Sorry, I missed that message. What are you expecting Lean core to do here? Because we are constructing a Perhaps @kmill should have a look at this and suggest if we can avoid this manual construction in the first place (and confirm whether the PR in its current state is still an improvement over the status quo). |
Batteries/Tactic/Lint/Frontend.lean
Outdated
| match ← withCurrHeartbeats (linter.test decl) | ||
| |>.run' mkMetaContext | ||
| |>.run' {options, fileName := "", fileMap := default} {env} | ||
| |>.run' {options, fileName := "", fileMap := default, initHeartbeats } {env} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the withCurrHeartbeats sets initHeartbeats from IO.getNumHeartbeats. What effect does initializing initHeartbeats here have? Can you come up with a test that validates this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, this has no effect.
Batteries/Util/Cache.lean
Outdated
| let initHeartbeats ← IO.getNumHeartbeats | ||
| let res ← EIO.asTask <| | ||
| init {} |>.run' {} { options, fileName, fileMap } |>.run' { env } | ||
| init {} |>.run' {} { options, fileName, fileMap, initHeartbeats } |>.run' { env } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that Lean.Core.wrapAsync exists, and it does a bit more heartbeats arithmetic. Lean.Core.CoreM.toIO looks relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrapAsync indeed looks like the right tool, as otherwise the hearbeat counts on one thread are meaninglessly transferred to another thread.
In only one case a `Core.Context` is created from within CoreM, and we inherit from the parent Context the `initHeartbeats`. Otherwise, we get the current heartbeats from IO. Co-authored-by: Laurent Sartran <[email protected]>
c753fca to
9d7fca8
Compare
|
Have issues been fixed to everyone's satisfaction? |
|
I'm afraid I lost track of this one. What's the current status? |
|
I need to update the description to reflect the new version, but I think the approach now aligns with @kmill's suggestion. The mathlib failure suggests that either I have broken the heartbeat counting, or that we were previously erroneously resetting the heartbeat counter mid-linter. |
In only one case a
Core.Contextis created from within CoreM, and we inherit from the parent Context theinitHeartbeats. Otherwise, we get the current heartbeats from IO.It's not entirely clear to me what the intended semantics of
lintCoreare; should they inherit the outer heartbeat count (as with this patch), or get a new heartbeat budget for each declaration (prior to it)?