Skip to content

gh-117645: Increase WASI stack size from 512 KiB to 8 MiB #117674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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):
Expand Down Expand Up @@ -134,7 +134,6 @@ def test_eval_gives_lambda_custom_globals(self):

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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2359,9 +2359,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"])
]
)

Expand Down