Zulip Chat Archive

Stream: lean4

Topic: Comparing how long it takes to open an empty Lean file


Julian Berman (Jul 16 2025 at 04:16):

I've been doing some light microbenchmarking to try and understand why lean.nvim's test suite takes 30 seconds to run (it does a lot of creating throwaway Lean files). In the process I've been poking at differences in how long it takes to open a Lean file and get a sign from the LSP that Lean is ready to go. I'm not sure I have a real question or point yet but perhaps the below is interesting to someone -- I presume someone more familiar than I am with the details of lake serve's startup will know more precisely what's happening in the startup procedure in each scenario below.

Specifically I timed how long it takes to open a Lean file and have it be ready to go in a few scenarios: 1 as a top level file in a Lean package with fewer dependencies, 2) a standalone file outside of a project 3) as a toplevel file in a project with heavier dependencies (Mathlib) 4) inside of the packages themselves 5) opening an existing file (I picked some random one from lean4export)

Here's the results below:

Time until $/lean/fileProgress says we're done processing our file

If we instead only wait until we start processing a file (i.e. until yellow bars show up), the results on my machine look like:

Time until $/lean/fileProgress says we started processing

and here there is at least a minor interesting thing to note which is that there is a decent size cost paid when opening a standalone file until lake notices there is no lakefile and falls back to lean --server. Sometimes this is a full second of lost time. Again I'm not sure this is an area of interest but perhaps there's a bit of optimization possible there (e.g. by having the elan wrappers do a quick check for a lakefile before even trying to invoke lake?)

For completeness here's my silly microbenchmark script in case anyone cares to try it:

microbench.lua

(all the actual files in the hyperfine line don't exist on disk, other than Export.lean of course)


Last updated: Dec 20 2025 at 21:32 UTC