google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.26k stars 204 forks source link

Limit CPU and memory usage for int-to-float conversion #515

Closed marco6 closed 8 months ago

marco6 commented 8 months ago

This PR adds a fast path for very big int to float conversion that always get converted to ±Inf.

adonovan commented 8 months ago

This PR adds a fast path for very big int to float conversion that always get converted to ±Inf.

Was this change opportunistic, or did the logic appear in a profile? I'm curious what workload would make heavy use of numbers larger than the universe.

marco6 commented 8 months ago

Opportunistic: we had to do that for concerns not related to performance and it felt in line with the previous optimization.

adonovan commented 8 months ago

In any case, looks good. Thanks for the contribution.