Zulip Chat Archive

Stream: mathlib4

Topic: maxHeartbeats


Jeremy Tan (May 05 2023 at 14:17):

Mauricio Collares said:

I can add the shameful maxHeartbeats bumps to !4#3457 myself :)

maxHeartbeats is never shameful. As long as it does the job it's OK

Patrick Massot (May 05 2023 at 14:22):

No, "As long as it does the job it's ok" is wrong.

Patrick Massot (May 05 2023 at 14:22):

It is the last thing to do when everything else failed.

Eric Wieser (May 05 2023 at 14:24):

Sometimes we've opted to set a highmaxHearbeats even when there was an alternative, because the alternative was just too ugly; with the hope that a future lean4 refactor will speed things up. That way we have no hack left to revert.

Mauricio Collares (May 05 2023 at 14:29):

Eric Wieser said:

Sometimes we've opted to set a highmaxHearbeats even when there was an alternative, because the alternative was just too ugly; with the hope that a future lean4 refactor will speed things up. That way we have no hack left to revert.

A particular case: when bumping maxHeartbeats is not needed in the reenableeta branch, hacky solutions should arguably be accepted less often.

Matthew Ballard (May 05 2023 at 15:52):

Yeah, bumping the heartbeats is not necessary on reenableeta.

Scott Morrison (May 05 2023 at 22:19):

I think also one should not add maxHeartbeats unless you've checked in mathlib3 how slow that declaration was, and noted in the porting comment whether this is a regression or just something that was already slow.

Xavier Roblot (May 06 2023 at 05:48):

Scott Morrison said:

I think also one should not add maxHeartbeats unless you've checked in mathlib3 how slow that declaration was, and noted in the porting comment whether this is a regression or just something that was already slow.

I had to add a bunch of maxHeartbeats to port !4#3777. Was I not supposed to do that? What are the other options?

Also, how do you test how slow a declaration is in mathlib3?

Scott Morrison (May 06 2023 at 05:59):

Also, how do you test how slow a declaration is in mathlib3?

set_option profiler true

(I guess you could also set_option timeout N for some N less than the default 100000.)

Scott Morrison (May 06 2023 at 05:59):

Or just eyeball how long the yellow bar takes. :-)

Scott Morrison (May 06 2023 at 06:02):

Usually when I encountered a maxHeartbeats problem, I:

set_option trace.profiler true in
set_option trace.Meta.synthInstance true in
set_option trace.Meta.isDefEq true in

and then look to see if I can see what is going wrong. Sometimes you can guess from the output if there is a bad instance. (e.g. I just noticed https://github.com/leanprover-community/mathlib/pull/18951 from looking at these trace outputs for the timeout that occurred on !4#3780.)

Scott Morrison (May 06 2023 at 06:03):

It's not a science, and if nothing is obvious then just putting the increased timelimits and noting them in the PR description is fine.

Notification Bot (May 06 2023 at 08:32):

12 messages were moved here from #mathlib4 > !4#3388 (revert porting of to_interval_mod) by Eric Wieser.

Mauricio Collares (May 06 2023 at 08:47):

In !4#3457, the expensive steps for the Ideal.Quotient.normedAlgebra instance seem to be AddCommMonoid.toAddMonoid =?= SubNegMonoid.toAddMonoid and SubNegMonoid.toAddMonoid =?= AddMonoidWithOne.toAddMonoid

Kevin Buzzard (May 06 2023 at 09:06):

@Sebastien Gouezel are you able to apply a small permutation to mathlib to make this issue far less prevalent? Is this the sort of question which a small permutation might solve?

Sebastien Gouezel (May 06 2023 at 09:17):

It's all a question of balance: maybe you can do it better here by a small perturbation, but it is likely that it will have some influence elsewhere, which could be positive or negative. The good news is that mathlib is now large enough that such tests are meaningful on the global scale. The bad news is that it takes time.

Kevin Buzzard (May 06 2023 at 20:26):

I'm very impressed that your permutation made so many of the files green in the bench. Was it precalculated or did it come from experimentation?

Scott Morrison (May 08 2023 at 01:57):

A fun data point: of the 31 set_option maxHeartbeats commands in current master, 29 are not needed in the reenableeta branch. !4#3845.

Scott Morrison (May 08 2023 at 02:00):

If anyone feels like fixing the 2 "genuine" ones, they are src4#CategoryTheory.Limits.pullbackDiagonalMapIso and src4#Matrix.det_mul. Apparently I wasn't actually at master, and one of those is already fixed.

Heather Macbeth (May 08 2023 at 02:02):

Is the reenableeta branch globally faster, on any benchmark?

Scott Morrison (May 08 2023 at 02:02):

Yes, considerably faster.


Last updated: Dec 20 2023 at 11:08 UTC