oxc-project / backlog

backlog for collborators only
0 stars 0 forks source link

Store `Semantic` data in arena #31

Open overlookmotel opened 2 months ago

overlookmotel commented 2 months ago

Semantic's data structures seem like a good candidate for arena allocation - lots of small structures built in a short space of time and then dropped simultaneously (much like the AST itself).

Semantic<'a> already has a lifetime, so moving the data into arena would not affect ergonomics of API.

The one downside of the arena allocator is that Vecs never grow in place, they always reallocate and are copied when they grow beyond capacity, because bumpalo packs data tightly and grows downwards.

This problem could be largely ameliorated if:

Additional benefits:

overlookmotel commented 2 months ago

We should probably store Semantic in a separate arena from AST itself, so AST remains compact in memory.

oxc_allocator::Allocator could contain both arenas:

struct Allocator {
  ast_arena: bumpalo::Bump,
  semantic_arena: bumpalo::Bump,
}