> ## Documentation Index
> Fetch the complete documentation index at: https://docs.proofpod.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Performance

> Cold and warm sandboxes, the fixed cost of a Mathlib build check, and how to keep commands fast.

Most of the time a cloud command is limited by the same things as a local one:
how much Lean has to elaborate, and how many cores it can use. Three costs are
specific to ProofPod: starting a new sandbox, Lake's up-to-date check through
the sandbox's filesystem, and the one-time build of a new environment.

## Warm sandboxes

After a command finishes, its sandbox stays warm for two minutes. A command that
arrives in that window starts in about a second and finds file caches already
populated. You are not billed for warm time.

A sandbox is reused when the next command in the same workspace asks for the
same versions and the same `--cpu` and `--memory`. Changing any of those starts
a fresh sandbox, which is slower for the first command. If you alternate
between two sets of limits, put the larger one in
[`proofpod.toml`](https://docs.proofpod.dev/reference/config) and use it for everything: unused
headroom is free.

## Cold starts

A sandbox that has been idle for more than two minutes is shut down. The next
command starts a new one, which has to read Mathlib's files for the first time:
the first `lake build` in a new sandbox spends 15 to 30 seconds reading
Mathlib's build metadata before it compiles anything.

Measured on a small project that imports all of Mathlib (Lean 4.36, default
4 cores):

| Command | New sandbox | Warm sandbox |
| - | -: | -: |
| `lake build`, nothing to rebuild | 25 – 40 s | 10 s |
| `lake env lean File.lean` | 15 – 27 s | 7 s |

## Builds with nothing to rebuild

Before compiling, Lake checks that every module your project depends on is up
to date. With Mathlib that is about 18,000 build records, and reading them
through the sandbox's filesystem takes about ten seconds. The same check takes
two or three seconds on a local SSD.

This overhead is fixed, so it disappears into any build that does real work.
For a tight edit-check loop on one file, skip the build:

```console theme={null}
$ pp lake env lean Proofs/Current.lean
```

More cores shorten the check, and limits are free: `pp --cpu 16 lake build`.

## First use of a version

If nobody has used your exact Lean and Mathlib versions before, the first
command builds that environment. It takes about five minutes for a Mathlib
environment, happens once per version for everyone, and is free. `pp envs`
lists the versions that are already built. See
[Prebuilt environments](https://docs.proofpod.dev/guide/environments.md).

## Summary

| To | Do |
| - | - |
| Keep consecutive commands fast | Run them within two minutes of each other, with the same limits and versions. |
| Check one file quickly | `pp lake env lean File.lean` instead of `pp lake build`. |
| Speed up a parallel build | Raise `--cpu`. You pay for the cores used, not the limit. |
| Avoid a cold cache in CI | Use a [named workspace](https://docs.proofpod.dev/guide/ci.md#share-a-workspace-between-jobs). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.