forked from google/starlark-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starlark: fall back to slow Ints if mmap fails (google#398)
The Int optimization uses a 4GB virtual address allocation to represent 32-bit values as addressed to avoid allocation. However, some environments have limited address space. This change permits the mmap to fail, and in that case it prints a warning and falls back to always allocating a big.Int, even for small numbers. Each access to an Int must check the smallints global to see whether the optimization is active. The extra dynamic check doesn't cost much: $ go test -run=nope -bench=BenchmarkStarlark -count=3 ./starlark # > before, after $ go install golang.org/x/perf/cmd/benchstat@latest $ ~/go/bin/benchstat before after name old time/op new time/op delta Starlark/bench_bigint-16 206µs ± 0% 212µs ± 0% ~ (p=0.100 n=3+3) Starlark/bench_builtin_method-16 283µs ± 1% 294µs ± 9% ~ (p=1.000 n=3+3) Starlark/bench_calling-16 280µs ± 1% 290µs ± 1% ~ (p=0.100 n=3+3) Starlark/bench_gauss-16 9.30ms ± 5% 9.55ms ± 2% ~ (p=0.700 n=3+3) Starlark/bench_int-16 53.7µs ± 1% 59.6µs ± 1% ~ (p=0.100 n=3+3) Starlark/bench_mix-16 99.3µs ± 1% 106.6µs ±10% ~ (p=0.100 n=3+3) Starlark/bench_range_construction-16 238ns ± 1% 244ns ± 2% ~ (p=0.100 n=3+3) Starlark/bench_range_iteration-16 5.44µs ± 2% 5.67µs ± 1% ~ (p=0.100 n=3+3) Also: - Add a linux-only test. - Simplify the build tags now that the 64-bit POSIX exceptions (iOS, openbsd) are handled dynamically. As a side effect, M1-based Macs should get the optimization for the first time. (Requires updating sys module.) - Update Actions tests to go1.18, 1.19, and drop 1.16 and 1.17. Fixes google#394 Co-authored-by: Alan Donovan <[email protected]>
- Loading branch information
Showing
8 changed files
with
96 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters