Skip to content
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

fix: add missing initHeartbeats #1037

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eric-wieser
Copy link
Member

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.

It's not entirely clear to me what the intended semantics of lintCore are; should they inherit the outer heartbeat count (as with this patch), or get a new heartbeat budget for each declaration (prior to it)?

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]>
@github-actions github-actions bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Nov 11, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 11, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@fgdorais
Copy link
Collaborator

LGTM Could you explain, for documentation purposes, why this isn't something Lean core could do?

@fgdorais fgdorais added awaiting-author Waiting for PR author to address issues and removed awaiting-review This PR is ready for review; the author thinks it is ready to be merged. labels Nov 26, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label Dec 2, 2024
@eric-wieser
Copy link
Member Author

Sorry, I missed that message.

What are you expecting Lean core to do here? Because we are constructing a Lean.Core.Context manually from scratch, it's our responsibility to fill in all of its fields.

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).

@@ -108,7 +109,7 @@ def lintCore (decls : Array Name) (linters : Array NamedLinter) :
BaseIO.asTask do
match ← withCurrHeartbeats (linter.test decl)
|>.run' mkMetaContext
|>.run' {options, fileName := "", fileMap := default} {env}
|>.run' {options, fileName := "", fileMap := default, initHeartbeats } {env}
Copy link
Contributor

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?

let res ← EIO.asTask <|
init {} |>.run' {} { options, fileName, fileMap } |>.run' { env }
init {} |>.run' {} { options, fileName, fileMap, initHeartbeats } |>.run' { env }
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Waiting for PR author to address issues builds-mathlib merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants