improve ddb TransactWriteItems performance + small refactor #10464
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.
Motivation
Follow up from #10415 and especially #9410 where we refactored the logic for
BatchWriteItem
.TransactWriteItems
had not been touched by the new changes, and should improve a lot from this.Changes
BatchWriteItem
, but slightly modified to account for the differencesTransactWriteItems
as there were nonedeepcopy
in the event creation in favor of just creating a new event (avoid pickling/unpickling).Benchmarks
Funnily enough, the changes are smaller than expected: Twisted, directly calling DynamoDB local without going through the Gateway, plus Kinesis batching relieving pressure on the gateway already improved the speed of
TransactWriteItems
by quite a lot compared to for example3.2
, so the gains are not so massive as we've been used to (still around 2x to 4x).I've added
3.2.0
to the benchmarks to show how far we've come in around 2 weeks.latest
andwith fix
are done with Twisted.3.2.0
did not have it yet, so it's still withhypercorn
.TransactWriteItems (10)
throughput item/sTransactWriteItems (25)
throughput item/sTransactWriteItems
(10) total seconds (5k items)TransactWriteItems
(25) total seconds (12k5 items)TransactWriteItems
(10) throughput item/sTransactWriteItems
(25) throughput item/sTransactWriteItems
(10) total seconds (5k items)TransactWriteItems
(25) total seconds (12k5 items)TransactWriteItems
(10) throughput item/sTransactWriteItems
(25) throughput item/sTransactWriteItems (10)
total seconds (5k items)TransactWriteItems (25)
total seconds (12k5 items)So in the end, we can still provide a 2x to 3.5x improvement over
latest
.For a batch size of 25 with no streams, we already provided a 5x improvement with
latest
, pushed to 17.5x.For a batch size of 25 with streams enabled, we already provided a 15x improvement, pushed to an average of 35x.