Zulip Chat Archive

Stream: lean4

Topic: profiling a project


Floris van Doorn (Feb 19 2025 at 11:10):

I want to look for some excessive slow declarations in the Carleson project. What is the best way to find these (without visiting every file manually)? I tried adding the following to my lakefile.toml:

[leanOptions]
profiler = true
profiler.threshold = 1000

But that gives the error error: lakefile.toml:15:0: error: cannot redefine value key 'leanOptions.profiler'

Floris van Doorn (Feb 19 2025 at 11:11):

Something that prints the per-file compilation time would also be very helpful.

Floris van Doorn (Feb 19 2025 at 11:12):

Where is the source code that generates https://speed.lean-lang.org/ ?

Sebastian Ullrich (Feb 19 2025 at 12:23):

That looks like a Lake bug

Sebastian Ullrich (Feb 19 2025 at 12:28):

Floris van Doorn said:

Where is the source code that generates https://speed.lean-lang.org/ ?

https://github.com/leanprover-community/mathlib4/blob/master/scripts/bench/temci-config.run.yml

Sebastian Ullrich (Feb 19 2025 at 12:29):

The simplest setup is to loop over all files in the project and run lake env time lean -Dprofiler... separately on them, then you don't have to worry about parallelism overhead either

Floris van Doorn (Feb 19 2025 at 12:42):

Sebastian Ullrich said:

That looks like a Lake bug

lean4#7147

Floris van Doorn (Feb 19 2025 at 12:42):

Thanks for the pointers!

Floris van Doorn (Feb 19 2025 at 13:17):

For future reference, this gives you a per-file compilation time: (run lake build first)

find Carleson -type f -iname "*.lean" -exec printf "\n{}\n" \; -exec lake env time lean {} \; >& timing.out

Floris van Doorn (Feb 19 2025 at 13:20):

You can add -Dprofiler=true after the lean command to also profile each file.

Floris van Doorn (Feb 19 2025 at 13:20):

This also shows all info/warning messages, even when I pass the -q option, as follows:

lake env time lean -q MyFile.lean

Is that intended?

Sebastian Ullrich (Feb 19 2025 at 13:28):

I think that flag hasn't done anything in any Lean 4 version. So I don't even remember anymore what its exact semantics in Lean 3 were.


Last updated: May 02 2025 at 03:31 UTC