From 10c945beab3fede4053fb8b202426b8bec25dfbf Mon Sep 17 00:00:00 2001 From: HASUMI Hitoshi Date: Mon, 26 Oct 2026 16:18:04 +0900 Subject: [PATCH] [ruby/prism] Let an embedder set PM_ARENA_INITIAL_SIZE The arena's first block is 8 KB, sized for a host. An embedder on a small heap parses short programs (a REPL line uses about 6 KB in two arenas) and pays two 8 KB blocks for each; with the constant under #ifndef it can build with -DPM_ARENA_INITIAL_SIZE=2048 instead. https://github.com/ruby/prism/commit/f7a062efd4 --- prism/arena.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prism/arena.c b/prism/arena.c index 64a731649d7..323c5bdc7d5 100644 --- a/prism/arena.c +++ b/prism/arena.c @@ -12,8 +12,13 @@ */ #define PM_ARENA_BLOCK_SIZE(data_size) (offsetof(pm_arena_block_t, data) + (data_size)) -/** Initial block data size: 8 KB. */ +/** + * Initial block data size: 8 KB. An embedder on a small heap can define a + * smaller one; a parse of a short program then takes blocks of that size. + */ +#ifndef PM_ARENA_INITIAL_SIZE #define PM_ARENA_INITIAL_SIZE 8192 +#endif /** Double the block size every this many blocks. */ #define PM_ARENA_GROWTH_INTERVAL 8