sashapolo commented on code in PR #5237: URL: https://github.com/apache/ignite-3/pull/5237#discussion_r1974202014
########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/raft/ZonePartitionRaftListener.java: ########## @@ -68,18 +72,27 @@ public class ZonePartitionRaftListener implements RaftGroupListener { /** Mapping table ID to table request processor. */ private final Map<Integer, RaftTableProcessor> tableProcessors = new ConcurrentHashMap<>(); + private final TxStatePartitionStorage txStateStorage; + private final PartitionsSnapshots partitionsSnapshots; private final PartitionKey partitionKey; /** - * Latest committed configuration of the zone-wide Raft group. + * Last applied index across all table processors. * - * <p>Multi-threaded access is guarded by {@link #commitedConfigurationLock}. + * <p>Multi-threaded access is guarded by {@link #tableProcessorsStateLock}. */ - private CommittedConfiguration currentCommitedConfiguration; + private long lastAppliedIndex; - private final Object commitedConfigurationLock = new Object(); + /** + * Last applied term across all table processors. + * + * <p>Multi-threaded access is guarded by {@link #tableProcessorsStateLock}. + */ + private long lastAppliedTerm; + + private final Object tableProcessorsStateLock = new Object(); Review Comment: I wrote the following benchmark, where we simply take and release locks: ``` @Benchmark public void usingObjectLock(ObjectLock lock, Blackhole blackhole) { synchronized (lock.lock) { blackhole.consume(1); } } @Benchmark public void usingSimpleLock(SimpleLock lock, Blackhole blackhole) { lock.lock.lock(); try { blackhole.consume(1); } finally { lock.lock.unlock(); } } @Benchmark public void usingRwLock(RwLock lock, Blackhole blackhole) { lock.lock.readLock().lock(); try { blackhole.consume(1); } finally { lock.lock.readLock().unlock(); } } ``` I have two threads executing each test concurrently. Here are the results: ``` Benchmark Mode Cnt Score Error Units LockingBenchmark.usingObjectLock thrpt 10 50282.577 ± 19986.306 ops/ms LockingBenchmark.usingRwLock thrpt 10 16178.064 ± 179.699 ops/ms LockingBenchmark.usingSimpleLock thrpt 10 29090.276 ± 10832.323 ops/ms ``` As you can see `synchornized` performs better in this scenario. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org