Skip to content

Use 32byte structs rather than byte[] in StorageTrie #8442

Open
@benaadams

Description

@benaadams

Is your feature request related to a problem? Please describe.

As well as allocating and having an indirection a byte[]

Has 24 bytes of header

  • Object header: 16 bytes total
    • 8 bytes for the sync block
    • 8 bytes for the method table pointer
  • Array length field: 4 bytes (stored as an Int32)
  • Padding: Up to 4 bytes added so that the total object size is a multiple of 8 bytes

Then 8 bytes for the pointer

So is already 32 bytes without any data; so might as well use a 32byte struct rather than a 64byte array (32bytes+32bytes); since all values are treated as unique and don't really share byte[] for leaf values

Describe the solution you'd like

Use using Word = Vector256<byte> Words instead of byte[]; this should reduce GC objects considered and use less memory (since even 1 byte is 33 bytes)

Describe alternatives you've considered

Leaving it unchanged

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions