SIGN IN SIGN UP

Memoize the options snapshot (#21354)

The `options_snapshot` is about 6% of CPU on incremental runs in a very
large codebase.

This caches the `(platform, hash_digest)` tuple keyed by `id()` of the
cloned `Options`, and keeps each cloned object alive in a parallel
`_options_snapshot_keepalive` list so `id()` cannot be reused by the GC
after a transient clone is collected.

This improved the overall time by roughly 5%, the time taken in the
function dropped by ~67% on a warm run, and the ~110k calls dropped to
~220 distinct cloned `Options` without any change in output
K
Kevin Kannammalil committed
f8bf7ab5778e5c68417c850aa7e4ca2e0b74f149
Parent: e0c375a
Committed by GitHub <noreply@github.com> on 6/12/2026, 4:52:37 PM