Closed adonovan closed 2 years ago
Ping @brandjon...
Ping?
Seems reasonable. Would be good to have a test, though (e.g. set RLIMIT_AS, see if int tests still pass).
Done, though it's a pain because it requires fork+execing a child process, and it requires ulimit -v which is not available on MacOS or Windows.
@tetromino, PTAL at the changes to the build tags, go.mod/sum files, Actions workflow config, and of course the test.
The Int optimization uses a 4GB virtual address allocation to represent 32-bit values as addresses 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:
Also, a linux-only test.
Also, 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.)
Fixes #394