Crazy idea: Use something like compact_arena for rustc?

rustc has a variety of arenas for various objects. On 64 bit systems (which are the majority of systems rustc is used on), this means each reference to an arena-allocated object takes 8 bytes.

The compact_arena crate has a proof-of-concept for (currently Vec- or array-based) arenas that use {8, 16, 32}-bit indices instead of pointers, thus allowing some memory savings (not to forget, those arenas work generatively, so we don't lose performance on lookup).

As our AST, HIR and MIR data appears to be highly size-sensitive, it may be a good idea to investigate if we could implement those memory savings and if they'd turn into a performance benefit.

Idx and IndexedVec already abstract between u32 and usize indexes. Do you know of places that aren't using this yet, but should?

I knew about Idx/IndexedVec, but a) those aren't used as arenas as far as I know of, and thus b) don't allow for generativity (and in effect safe unchecked indexing) – this only works because the elements are in the arena until the end.

On the other hand, the typed arenas currently in use by the global context return refs, and AST and HIR use owned pointers (P) extensively. I don''t think those are compressed for now, right?