aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-04-16 23:26:54 +0200
committerGitHub <noreply@github.com>2024-04-16 23:26:54 +0200
commit919784737c69e0f8e34d7d7a2e85b02628af6e66 (patch)
treec41e2cc503f45d50968c98c892c1242a73696566
parent3fe03ccea61121b05e933013f76aa02f690014c1 (diff)
downloadcpython-919784737c69e0f8e34d7d7a2e85b02628af6e66.tar.gz
cpython-919784737c69e0f8e34d7d7a2e85b02628af6e66.zip
gh-117645: Increase WASI stack size from 512 KiB to 8 MiB (#117674)
Increase also the initial memory from 10 MiB to 20 MiB. Reenable test_dynamic on WASI build.
-rw-r--r--Include/cpython/pystate.h11
-rw-r--r--Lib/test/test_dynamic.py3
-rw-r--r--Misc/NEWS.d/next/Build/2024-04-09-12-59-06.gh-issue-117645.0oEVAa.rst2
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac5
5 files changed, 10 insertions, 13 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 7fb6b176392..6d5dba2bf37 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -198,14 +198,6 @@ struct _ts {
#ifdef Py_DEBUG
// A debug build is likely built with low optimization level which implies
// higher stack memory usage than a release build: use a lower limit.
-# if defined(__wasi__)
- // Based on wasmtime 16.
-# define Py_C_RECURSION_LIMIT 150
-# else
-# define Py_C_RECURSION_LIMIT 500
-# endif
-#elif defined(__wasi__)
- // Based on wasmtime 16.
# define Py_C_RECURSION_LIMIT 500
#elif defined(__s390x__)
# define Py_C_RECURSION_LIMIT 800
@@ -219,6 +211,9 @@ struct _ts {
# define Py_C_RECURSION_LIMIT 3000
#elif defined(_Py_ADDRESS_SANITIZER)
# define Py_C_RECURSION_LIMIT 4000
+#elif defined(__wasi__)
+ // Based on wasmtime 16.
+# define Py_C_RECURSION_LIMIT 5000
#else
// This value is duplicated in Lib/test/support/__init__.py
# define Py_C_RECURSION_LIMIT 10000
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
index 0cb56a98f1c..0aa3be6a1bd 100644
--- a/Lib/test/test_dynamic.py
+++ b/Lib/test/test_dynamic.py
@@ -4,7 +4,7 @@ import builtins
import sys
import unittest
-from test.support import is_wasi, swap_item, swap_attr
+from test.support import swap_item, swap_attr
class RebindBuiltinsTests(unittest.TestCase):
@@ -134,7 +134,6 @@ class RebindBuiltinsTests(unittest.TestCase):
self.assertEqual(foo(), 7)
- @unittest.skipIf(is_wasi, "stack depth too shallow in WASI")
def test_load_global_specialization_failure_keeps_oparg(self):
# https://github.com/python/cpython/issues/91625
class MyGlobals(dict):
diff --git a/Misc/NEWS.d/next/Build/2024-04-09-12-59-06.gh-issue-117645.0oEVAa.rst b/Misc/NEWS.d/next/Build/2024-04-09-12-59-06.gh-issue-117645.0oEVAa.rst
new file mode 100644
index 00000000000..83df6338c29
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2024-04-09-12-59-06.gh-issue-117645.0oEVAa.rst
@@ -0,0 +1,2 @@
+Increase WASI stack size from 512 KiB to 8 MiB and the initial memory from 10
+MiB to 20 MiB. Patch by Victor Stinner.
diff --git a/configure b/configure
index 80403255a81..6782d470aad 100755
--- a/configure
+++ b/configure
@@ -9530,7 +9530,7 @@ then :
fi
- as_fn_append LDFLAGS_NODIST " -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760"
+ as_fn_append LDFLAGS_NODIST " -z stack-size=8388608 -Wl,--stack-first -Wl,--initial-memory=20971520"
;; #(
*) :
diff --git a/configure.ac b/configure.ac
index ec925d4d4a0..51a0d35dbc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2384,9 +2384,10 @@ AS_CASE([$ac_sys_system],
AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--max-memory=10485760"])
])
- dnl increase initial memory and stack size, move stack first
+ dnl gh-117645: Set the memory size to 20 MiB, the stack size to 8 MiB,
+ dnl and move the stack first.
dnl https://github.com/WebAssembly/wasi-libc/issues/233
- AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760"])
+ AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=8388608 -Wl,--stack-first -Wl,--initial-memory=20971520"])
]
)