- Notifications
You must be signed in to change notification settings - Fork 793
Closed
Description
When investigating issue #1116, I came across (duplicated) code in SearchHelper and SearchEngine classes which looks like this:
209 for (Project project : root) { 210 IndexReader ireader = (DirectoryReader.open(FSDirectory.open(new File(droot, project.getPath()).toPath()))); 211 subreaders[ii++] = ireader; 212 } 213 MultiReader searchables = new MultiReader(subreaders, true); 214 if (Runtime.getRuntime().availableProcessors() > 1) { 215 int noThreads = 2 + (2 * Runtime.getRuntime().availableProcessors()); //TODO there might be a better way for counting this - or we should honor the command line option here too! 216 ExecutorService executor = Executors.newFixedThreadPool(noThreads); 217 searcher = new IndexSearcher(searchables, executor); 218 } else { 219 searcher = new IndexSearcher(searchables); 220 } Basically this means that for each multi-project search, new separate thread pool will be created. If the server receives couple of multi-project requests at once, many threads can be created. This will lead to bad utilization of (already saturated) resources.
Firstly, the duplication should be dealt with. Secondly, the default value should be tunable. Lastly, the thread pool should be created just once for given webapp run.