LeanProfiler

2.6. Keep long captures finite🔗

A trace of every operation in a long training run can consume substantial memory and become harder to inspect than the program itself. Set a retained-event limit when the workload is not naturally small:

LEAN_PROFILE=1 \
LEAN_PROFILE_MAX_EVENTS=250000 \
lake exe your_executable

LeanProfiler retains the spans with the first 250,000 reserved indices. Later spans still run and unwind their local nesting stacks, but their records are dropped. The summary reports both the configured limit and dropped_events.

The retained prefix can still diagnose an early slowdown. It should not silently become a performance baseline for the whole run. The comparison command rejects dropped events and structural validation issues unless --allow-incomplete is supplied.

For repeated measurements, prefer a short scheduled capture after warmup rather than a very large prefix. Scheduled captures also make baseline and candidate runs easier to compare.