denis-chudov commented on a change in pull request #9243:
URL: https://github.com/apache/ignite/pull/9243#discussion_r686626721
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
##########
@@ -5524,58 +5527,91 @@ private void restorePartitionStates(
ExecutorService sysPool = ctx.pools().getSystemExecutorService();
- CountDownLatch completionLatch = new
CountDownLatch(forGroups.size());
-
AtomicReference<SortedSet<T3<Long, Long, GroupPartitionId>>>
topPartRef = new AtomicReference<>();
long totalPart = forGroups.stream().mapToLong(grpCtx ->
grpCtx.affinity().partitions()).sum();
- for (CacheGroupContext grp : forGroups) {
- sysPool.execute(() -> {
- try {
- Map<Integer, Long> processed =
grp.offheap().restorePartitionStates(partStates);
+ int poolSize = ctx.config().getSystemThreadPoolSize();
- totalProcessed.addAndGet(processed.size());
+ List<Queue<GroupPartitionId>> partIds = new ArrayList<>(poolSize);
- if (log.isInfoEnabled()) {
- TreeSet<T3<Long, Long, GroupPartitionId>> top =
- new TreeSet<>(processedPartitionComparator());
+ for (int i = 0; i < poolSize; i++)
+ partIds.add(new LinkedList<>());
- long ts = System.currentTimeMillis();
+ int cntr = 0;
- for (Map.Entry<Integer, Long> e :
processed.entrySet()) {
- top.add(new T3<>(e.getValue(), ts, new
GroupPartitionId(grp.groupId(), e.getKey())));
+ // Group id -> completed partitions counter
+ Map<Integer, AtomicInteger> grps = new HashMap<>();
- trimToSize(top, 5);
- }
+ for (CacheGroupContext ctx : forGroups) {
+ grps.put(ctx.groupId(), new AtomicInteger());
- topPartRef.updateAndGet(top0 -> {
- if (top0 == null)
- return top;
+ for (int i = 0; i < ctx.affinity().partitions(); i++)
+ partIds.get(cntr++ % poolSize).add(new
GroupPartitionId(ctx.groupId(), i));
+ }
+
+ CountDownLatch completionLatch = new CountDownLatch(cntr);
+
+ final int topPartRefLimit = 5;
+
+ for (int i = 0; i < poolSize; i++) {
+ final int batchIdx = i;
+
+ sysPool.execute(() -> {
+ Queue<GroupPartitionId> batch = partIds.get(batchIdx);
+
+ SortedSet<T3<Long, Long, GroupPartitionId>> top =
+ new
ConcurrentSkipListSet<>(processedPartitionComparator());
Review comment:
it's not used in single thread now
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]