symbol.c: use chunk-based pool for symbol string allocation

Replace per-symbol mrb_malloc() with a chunk-based string pool that
batches allocations into 4KB chunks. This reduces malloc call count
by ~12x (e.g. 909 vs 10,887 for 10k dynamic symbols) and eliminates
per-allocation malloc metadata overhead (~16 bytes/symbol).

Pool allocations are rounded up to even size to preserve LSB pointer
tagging used for literal detection.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-28 10:15:59 +09:00
parent 299eebaa23
commit e05bd8f806
2 changed files with 40 additions and 10 deletions
+1
View File
@@ -301,6 +301,7 @@ typedef struct mrb_state {
const char **symtbl;
size_t symcapa;
struct mrb_sym_hash_table *symhash;
void *sym_pool;
#ifndef MRB_USE_ALL_SYMBOLS
char symbuf[8]; /* buffer for small symbol names */
#endif