alex-plekhanov commented on code in PR #11984:
URL: https://github.com/apache/ignite/pull/11984#discussion_r2032806500


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java:
##########
@@ -1110,7 +1113,14 @@ private Metas getOrAllocateCacheMetas() throws 
IgniteCheckedException {
             int cleared = 0;
 
             // Use random shift to reduce contention.
-            int shift = 
ThreadLocalRandom.current().nextInt(F.size(cacheDataStores().iterator()));

Review Comment:
   Currently we create 3 `cacheDataStores()` iterators (in worst case). Your 
patch reduces it to 2 iterators. But we can use also reduce it to 1 iterator. 
We can introduce something like `randomShiftedLocalPartitionsIterator()` where 
locParts.length() - not requres any computations and we can calculate shift 
based on this array length. After it both following loops over 
`cacheDataStores()` can be combined to one.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/checkpoint/CheckpointWorkflow.java:
##########
@@ -379,7 +379,7 @@ private void fillCacheGroupState(CheckpointRecord cpRec) 
throws IgniteCheckedExc
                 continue;
 
             Runnable r = () -> {
-                ArrayList<GridDhtLocalPartition> parts = new 
ArrayList<>(grp.topology().localPartitions().size());
+                ArrayList<GridDhtLocalPartition> parts = new 
ArrayList<>(grp.topology().localPartitionsNumber());
 
                 for (GridDhtLocalPartition part : 
grp.topology().currentLocalPartitions())
                     parts.add(part);

Review Comment:
   Looks like just `localPartitions()` can be used instead of 
`currentLocalPartitions()`



-- 
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

Reply via email to