You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix exponential memory blowup in dict literal type inference
Summary:
Deeply-nested dict literals (e.g. `{"a": {"b": {"c": ...}}}`) caused exponential memory growth during type inference, with a depth-25 literal consuming ~7.7 GB and triggering OOM.
The root cause was `AnonymousTypedDictInner` storing both the individual `fields` and a pre-computed `value_type` (the union of all field types). Since `value_type` was a clone of the field types, each nesting level doubled the size of the type tree on `Clone`, producing O(2^N) memory usage.
The fix removes the redundant `value_type` field and instead computes it on demand via `compute_value_type()`. This ensures the type tree is only as deep as the actual nesting, reducing pyrefly's total memory for a depth-25 dict from ~7.7 GB to ~239 MB.
fixes#3286
Reviewed By: stroxler
Differential Revision: D103479382
fbshipit-source-id: 6734b427217ba54e5a3276291811bb77f98654f6
0 commit comments