Skip to content

Reduce peek memory use. #125

@roconnor-blockstream

Description

@roconnor-blockstream

Recent analysis shows that during Simplicity execution, peek memory use could be as high as 720 bytes per DAG node. We should rearrange computations and allocations to try to reduce that as much as possible. Ideally I'd like to see less than 128 bytes per DAG node if possible.

  • Postpone the CMR computation until after type inference, and move the CMR out of the dag structure. Only the Root CMR and one CMR per disconnect node is needed, so perhaps there is a way to keep only these placing the CMR in a union in the dag structure only accessible to disconnect.
  • Move the TMR out of the type structure. Compute it as part of the IMR computation and free it afterwards. (The IMR calculation seems to require up to 4*32 bytes per DAG node to just by itself, so keeping peek memory use under 128 bytes per DAG node seems impossible).
  • Replace all size_t values with uint32_t values. Ensure that the maximum index of arrays is less than 2^32.
  • Replace all unification_var* with a uint32_t value and rearrange the unification_var allocations so that they all are in one single array.
  • make an isChild field in unification_var instead of using a NULL pointer. Make the parent pointer part of a union.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions