8000 gh-117645: Increase WASI stack size from 512 KiB to 8 MiB (#117674) · python/cpython@9197847 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9197847

Browse files
authored
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.
1 parent 3fe03cc commit 9197847

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

Include/cpython/pystate.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,6 @@ struct _ts {
198198
#ifdef Py_DEBUG
199199
// A debug build is likely built with low optimization level which implies
200200
// higher stack memory usage than a release build: use a lower limit.
201-
# if defined(__wasi__)
202-
// Based on wasmtime 16.
203-
# define Py_C_RECURSION_LIMIT 150
204-
# else
205-
# define Py_C_RECURSION_LIMIT 500
206-
# endif
207-
#elif defined(__wasi__)
208-
// Based on wasmtime 16.
209201
# define Py_C_RECURSION_LIMIT 500
210202
#elif defined(__s390x__)
211203
# define Py_C_RECURSION_LIMIT 800
@@ -219,6 +211,9 @@ struct _ts {
219211
# define Py_C_RECURSION_LIMIT 3000
220212
#elif defined(_Py_ADDRESS_SANITIZER)
221213
# define Py_C_RECURSION_LIMIT 4000
214+
#elif defined(__wasi__)
215+
// Based on wasmtime 16.
216+
# define Py_C_RECURSION_LIMIT 5000
222217
#else
223218
// This value is duplicated in Lib/test/support/__init__.py
224219
# define Py_C_RECURSION_LIMIT 10000

Lib/test/test_dynamic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import unittest
66

7-
from test.support import is_wasi, swap_item, swap_attr
7+
from test.support import swap_item, swap_attr
88

99

1010
class RebindBuiltinsTests(unittest.TestCase):
@@ -134,7 +134,6 @@ def test_eval_gives_lambda_custom_globals(self):
134134

135135
self.assertEqual(foo(), 7)
136136

137-
@unittest.skipIf(is_wasi, "stack depth too shallow in WASI")
138137
def test_load_global_specialization_failure_keeps_oparg(self):
139138
# https://github.com/python/cpython/issues/91625
140139
class MyGlobals(dict):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Increase WASI stack size from 512 KiB to 8 MiB and the initial memory from 10
2+
MiB to 20 MiB. Patch by Victor Stinner.

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,9 +2384,10 @@ AS_CASE([$ac_sys_system],
23842384
AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--max-memory=10485760"])
23852385
])
23862386
2387-
dnl increase initial memory and stack size, move stack first
2387+
dnl gh-117645: Set the memory size to 20 MiB, the stack size to 8 MiB,
2388+
dnl and move the stack first.
23882389
dnl https://github.com/WebAssembly/wasi-libc/issues/233
2389-
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760"])
2390+
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=8388608 -Wl,--stack-first -Wl,--initial-memory=20971520"])
23902391
]
23912392
)
23922393

0 commit comments

Comments
 (0)
0