Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce peek memory use. #125

Open
5 tasks
roconnor-blockstream opened this issue Mar 23, 2023 · 0 comments
Open
5 tasks

Reduce peek memory use. #125

roconnor-blockstream opened this issue Mar 23, 2023 · 0 comments

Comments

@roconnor-blockstream
Copy link
Collaborator

roconnor-blockstream commented Mar 23, 2023

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant