[turbopack] Don't persist if there is little work to do (#95137)
Currently we skip a persist cycle when there are no dirty tasks. This PR
extends that to skip persist cycles when little compilation work has
happened since the last snapshot, avoiding small writes and expensive
compaction for little benefit.
Compilation time is a better proxy for "how much work a snapshot would
save" than a raw dirty-task count. The background snapshot loop
accumulates active (non-idle) wall-clock time and skips a cycle when
less than a threshold has elapsed since the last persisted snapshot.
Default is 1s, overridable via
`TURBO_ENGINE_SNAPSHOT_MIN_ACTIVE_TIME_MILLIS` (set to `0` in tests).
Shutdown and test snapshots bypass the gate.
The active-time bookkeeping is encapsulated in a small `Stopwatch`
helper.
<!-- NEXT_JS_LLM_PR -->