public class BatchedWriteTransaction
extends BaseCorfuAppUtils
Sometimes developers may group mutator operations into transactions for performance reasons.
This program runs two such workloads.
Workload 1:
This workload populates a large map with entries, in two ways,
- default, where one mutation is dumped to the log
- in batches, each batch is a "transaction", dumped to the log as an indivisible entry.
Running on my macbook, the first loop takes (roughly) 57 seconds, the second one 5 seconds.
The reason is that internally, the Corfu corfuRuntime sends updates to the Corfu log to persist.
When an application performs a bunch of individual updates, they are persisted one at a time,
each in a separate log entry.
In a transaction, the corfuRuntime waits until the transaction end and persists one (large) log entry
for the entire transaction. Writing one large entry takes much less time than many small ones.
Workload 2:
This workload also populates map entries in transaction batches. However, it works over a collection of maps.
Transactions perform updates to distinct streams.
Running again on a single mac-book, it takes (roughly) 59 seconds.
The reason is that, despite the transaction batching, each stream needs to persist the transaction independently.
So the load is the same as performing individual updates, one by one.
======
Note: For either workload, this sort of batching must be done with care,
to avoid causing false-sharing and inflicting aborts.
Created by dalia on 12/30/16.