]> git.kaiwu.me - njs.git/commitdiff
Change: increasing the default stack size to 160k.
authorDmitry Volyntsev <xeioex@nginx.com>
Mon, 11 Aug 2025 23:25:47 +0000 (16:25 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 12 Aug 2025 01:57:41 +0000 (18:57 -0700)
This change allows EarleyBoyer benchmark from
arewefastyet/benchmarks/v8-v7 to pass with default settings.

Previous commit 5e9a6d5 (v0.7.9) reduced the stack size to prevent stack
overflow when compiling with -O0 in computed goto mode, where native
stack frames for njs_vmcode_interpreter() consume ~80KB each. To address
this, we now set a lower maximum stack size specifically for unit tests.

This fixes #939 issue on Github.

src/njs_vm.h
src/test/njs_unit_test.c

index 3351dee4a2422ba4117066fe731d869902f53935..46f566e3c7f404980ecd0a15dc435350ef7ba360 100644 (file)
@@ -8,7 +8,7 @@
 #define _NJS_VM_H_INCLUDED_
 
 
-#define NJS_MAX_STACK_SIZE       (64 * 1024)
+#define NJS_MAX_STACK_SIZE       (160 * 1024)
 
 
 typedef struct njs_frame_s            njs_frame_t;
index 78e12197508464c796853ea658322cc25f5e77aa..67c57d19eadc0eefe820ee409f7654a27d4a6f6b 100644 (file)
@@ -21856,6 +21856,7 @@ njs_unit_test(njs_unit_test_t tests[], size_t num, njs_str_t *name,
         options.module = opts->module;
         options.unsafe = opts->unsafe;
         options.backtrace = opts->backtrace;
+        options.max_stack_size = 64 * 1024;
         options.addons = opts->externals ? njs_unit_test_addon_external_modules
                                          : njs_unit_test_addon_modules;
 
@@ -22008,6 +22009,7 @@ njs_interactive_test(njs_unit_test_t tests[], size_t num, njs_str_t *name,
         options.init = 1;
         options.interactive = 1;
         options.backtrace = 1;
+        options.max_stack_size = 64 * 1024;
         options.addons = opts->externals ? njs_unit_test_addon_external_modules
                                          : njs_unit_test_addon_modules;