Speed up options snapshot calculation (#20797)
The `options_snapshot` function was using up to 19% CPU in small
incremental runs in a very large codebase, when not using orjson.
Micro-optimize it, and use binary serialization instead of json.
We can still make this faster, but first let's see how much this helps.