Skip to content

Compact object headers #70

@markshannon

Description

@markshannon

How much space do the various fields of an object header need?

Field Currently uses Minimum Realistic goal
class 1 word (pointer) Depends on how many classes ~24 bits 1 word less 8 bits for alignment (it shouldn't be that hard to align class objects to 256 bytes, or to steal a few top bits for a few years before hardware needs all 64).
Reference count 1 word Half word or less using saturating reference counting 1 word less 3+n bits. Where 1/2**n is the fraction of memory that can be allocated to objects
GC data 2 words ~5 bits, plus external data for younger generations ~5 bits (can go in class word) + temporary ref count in top half of ref count
weakref 1 word 1 bit if no weakrefs 1 bit + external table when needed
Total 5 words 1 word 2 words

A 1 word header is going to be tricky and may well be so convoluted that it makes performance worse.
However I think the two word header is feasible.

The bits required for GC and finalization are:

  • Generation: 2 bits
  • Scratch bits: 2 bits (for internal GC state)
  • Needs finalizing: 1 bit
  • Has weakref: 1 bit

Of course, aiming for a two word header doesn't mean we can't improve things incrementally.
A three word header would still be a significant improvement and would be significantly simpler to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions