From f766d3eb712143caac6ce7a06cc834b7350cd3a0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 3 Mar 2016 15:19:44 +0300 Subject: [PATCH] use FJPool because all this resolve processing is too finegrained to deserve our app pool --- .../vfs/impl/local/CanonicalPathMap.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java index 69e7afd871bc..ab6a30595fc6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java @@ -15,26 +15,18 @@ */ package com.intellij.openapi.vfs.impl.local; +import com.intellij.concurrency.JobLauncher; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileSystemUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.concurrency.BoundedTaskExecutor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; -import org.jetbrains.ide.PooledThreadExecutor; import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.stream.Stream; +import java.util.*; import static com.intellij.openapi.util.Pair.pair; @@ -66,18 +58,19 @@ class CanonicalPathMap { } private static Map resolvePaths(Collection recursiveRoots, Collection flatRoots) { + Map before = Thread.getAllStackTraces(); + long start = System.currentTimeMillis(); Map result = ContainerUtil.newConcurrentMap(); - ExecutorService pool = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, Runtime.getRuntime().availableProcessors()); - CompletableFuture[] futures = Stream.concat(recursiveRoots.stream(), flatRoots.stream()) - .map(root -> CompletableFuture.runAsync(() -> ContainerUtil.putIfNotNull(root, FileSystemUtil.resolveSymLink(root), result), pool)) - .toArray(CompletableFuture[]::new); - - try { CompletableFuture.allOf(futures).get(); } - catch (InterruptedException | ExecutionException e) { - LOG.error(e); - } + List roots = ContainerUtil.concat(Arrays.asList(recursiveRoots, flatRoots)); + JobLauncher.getInstance().invokeConcurrentlyUnderProgress(roots, null, false, false, root -> { + ContainerUtil.putIfNotNull(root, FileSystemUtil.resolveSymLink(root), result); + return true; + }); + long finish = System.currentTimeMillis(); + Map after = Thread.getAllStackTraces(); + System.out.println((recursiveRoots.size()+flatRoots.size()) +" roots resolved. Before: " +before.size()+" threads; after: "+after.size()+" threads. Took "+(finish-start)+"ms"); return result; }