-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
khepri_tx_adv: Prefer list prepending to build side effect lists
In a transaction we build the set of `ra_machine:effect()`s for the machine to handle by using `++/2` with the old and new effects for each `khepri_tx`/`khepri_tx_adv` command. This is a noticeable bottleneck though when there are many (thousands or more) commands used in a transaction. `++/2` works by prepending every element in the left-hand side list (reversed) to the right-hand side list. As a transaction calls more `khepri_tx`/ `khepri_tx_adv` commands, the left-hand side list (old side effects) gets much longer than the right-hand side list (new side effects) and time it takes to append increases. We can avoid `++/2` by building the side effect list gradually and prepend every effect. The ordering of effects within a command isn't consequential: the effects update triggers and projections and each update is disjoint from the others. The ordering of the full side effect list is important though - a delete's effects should be handled before a put for the same path pattern for example - so we need to reverse the side effect list for the whole transaction before handling the effects.
- Loading branch information
1 parent
be71afe
commit ea0ea26
Showing
2 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters