Ed94 / gencpp

Staged metaprogramming in C++ for C/C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make a slab allocator for general string allocation

Ed94 opened this issue · comments

commented

All strings that are not cached for AST name or content fields are just dumped into the global allocator.
The global allocator itself is just array of arenas (buckets). There is no reuse of any allocated memory there.

Slab classes (for 100 mb arena)

1KB   slab: 5MB  ( 5MB  / 1KB   ~ 5,000 blocks )
4KB   slab: 10MB ( 10MB / 4KB   ~ 2,500 blocks )
16KB  slab: 15MB ( 15MB / 16KB  ~ 960 blocks   )
64KB  slab: 15MB ( 15MB / 64KB  ~ 240 blocks   )
256KB slab: 20MB ( 20MB / 256KB ~ 80 blocks    )
512KB slab: 20MB ( 20MB / 512KB ~ 40 blocks    )
1MB   slab: 15MB ( 15MB / 1MB   ~ 15 blocks    )