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

SimpleSmt insertion optimization #300

Open
polydez opened this issue Apr 2, 2024 · 2 comments
Open

SimpleSmt insertion optimization #300

polydez opened this issue Apr 2, 2024 · 2 comments
Milestone

Comments

@polydez
Copy link
Contributor

polydez commented Apr 2, 2024

Currently SimpleSmt recomputes inner node hashes on each insert. It computes and writes hashes starting from inserted node and up to the root. It might lead to unnecessary computations during bulk inserts (for example, SimpleSmt::with_leaves and SimpleSmt::with_contiguous_leaves use insert under the hood).

We can use different approaches for such optimization. For example:

  1. Simply disable hashes calculations during bulk inserts and then create all needed inner nodes with hashes computation after operation. This approach should work fine for populating constructors (with_leaves, and similar).
  2. Mark hashes, affected during insertion, as invalid. Recalculate lazily only invalid hashes on access to root hash. This is little more complex approach, but should work fine for random inserts.
@polydez
Copy link
Contributor Author

polydez commented Apr 3, 2024

I'd personally use both approaches, at least the first one (not sure, that we need to insert values randomly).

@bobbinth
Copy link
Contributor

bobbinth commented Apr 3, 2024

I would start with the first one - I think it should get us most of the benefit. The second one can be implemented much later (and only if we discover that we need it).

@bobbinth bobbinth added this to the v0.10.0 milestone May 20, 2024
@bobbinth bobbinth modified the milestones: v0.10.0, v0.11.0 Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants