Trick View variable search causes large spike in cpu usage
sharmeye opened this issue · 1 comments
Search a variable in Trick View causes a large spike in CPU usage, oftentimes resulting in overruns for a realtime simulation. Multithreaded search function appears to be at least partially responsible.
In Searcher.java,
127 threads = Runtime.getRuntime().availableProcessors();
...
130 executorService = Executors.newFixedThreadPool(threads);
allocates a threadpool with a thread for each processor in the system and searches for the desired text in the sie list.
Realtime sims will often have overruns during this search
Multithreaded searching was added to address complaints about how long single-threaded searching took. While there are probably ways to improve the efficiency, it is likely to consume all of the resources available to it for a least part of the search unless you explicitly throttle it. Reducing the size of the thread pool (based on the total number of processors) would leave more processors available for other processes. However, there's no guarantee that other high-CPU processes won't consume those processors as well, and now you risk unnecessarily longer search times if those other processors sit idle. Generally, managing CPU allocation is the job of the operating system, not applications. If you don't want other applications impacting a sim, a more robust solution is to run that sim on an isolated core. Nevertheless, your "Greedy Search" feature is a reasonable compromise.