ELSEIF
Your brief EB
170 stories from 125 feeds 520 clusters Refreshed 15 seconds ago next pull 13:43

PERFORMANCE Signal 414

C++ markdown parser AST nodes shrunk from 232 bytes to 16 bytes via pointer compression and arena allocation

A developer porting a Rust markdown parser to C++ reduced per-node memory from 232 bytes to 16 bytes using arena allocation, compressed string pointers, in-place arena string growth, and struct field packing.

WHY IT MATTERS

AST-based markdown parsers pay per-node overhead for every field regardless of node type, so node size directly drives memory consumption on large documents. The techniques shown, arena allocation, 32-bit pointer offsets, and in-place string growth, are transferable to any C++ project that builds large in-memory trees with uniform lifetime. The benchmarks show up to 75% memory reduction on entity-heavy input with no speed regression measured.

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

Compressing string pointers from 8 bytes to 4-byte arena offsets cut per-node overhead by 64 bytes, dropping nodes from 232 to 168 bytes.

02

Growing the last arena-allocated string in place eliminated dead copies from repeated allocations, cutting entity-heavy memory usage by 73.8%.

03

Reordering struct fields and packing bools reduced padding waste, contributing to the final 16-byte node size.

THE CLUSTER

Same story, 1 feed.

ORDERED BY FIRST SEEN
kowalczyk.info via Lobsters Optimizing memory usage in a markdown parser Open ↗