feat(x/intent): use fixed Intent in Actions and improve ActionsByAddress query performance #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ActionsByAddress was our slowest query, so it's the first one I'm tackling before v0.2 to improve performance on our nodes.
I benchmarked the current vs new implementation using a simple script:
on a node that has
45584
actions, of which only3
had to be returned by the query.After this PR:
Before this PR:
It's not a super precise benchmark, but I think it's reasonable to say that we gained at least an order of magnitude here, that will result in massive improvements in production since I didn't consider concurrent users and GC pressure.
This PR comes with an important breaking change, though:
Actions will store a fixed version of the Intent at the time the Action is created
This means, that if an Action was using the default Intent of the Space (i.e. "one of the owners"), the group of owners could change after the Action is created. In this new version, the list of owners is fixed at the time the Action is created and can't be changed later (the user can revoke this action and create a new one, if it needs it).
I personally think this is clearer and avoids unexpected flows with the Actions, especially if we'll allow to edit Intent definitions after creation (which is something we want to do).