Priority Constraints in RequestProcessor
The NetBeans RequestProcessor API does not provide a native mechanism to assign granular priority levels to individual requests. Tasks submitted to a single RequestProcessor instance are generally executed in a first-in, first-out (FIFO) manner. Consequently, there is no built-in configuration to allow a high-priority UI lookup to preempt a heavy background indexing task once it has been queued in the shared worker pool.
Proposed Implementation for Task Isolation
Since the API lacks per-request priority, the most effective way to prevent background indexing from exhausting the thread pool is to decouple the task types into separate RequestProcessor instances. This creates logical isolation, ensuring that indexing operations cannot saturate the threads reserved for UI-critical asynchronous work.
Steps to Isolate Indexing Tasks
- Define Separate Processors: Instead of using a global singleton, instantiate two distinct
RequestProcessor objects: one for UI_CRITICAL_PROCESSOR and one for BACKGROUND_INDEXING_PROCESSOR.
- Route Requests: Direct all code completion and lookup requests to the UI-critical processor and all heavy I/O or indexing tasks to the background processor.
- Manage EDT Transitions: Use
requestEDT() for the final UI update phase of both processors to ensure the Event Dispatch Thread remains responsive.
Assumptions and Technical Limitations
This approach assumes that the bottleneck is thread availability rather than CPU or Disk I/O saturation. If the underlying hardware is fully saturated by indexing I/O, separate processors will not eliminate latency, as the OS scheduler will still contend for resources.
Caution: Avoid creating an excessive number of RequestProcessor instances. Each instance manages its own resources; over-proliferation can lead to increased memory overhead and excessive context switching, which may degrade overall IDE performance.
Verification Method
To verify that isolation is working, you can use JVisualVM or a similar JVM profiling tool. Monitor the thread names and states while triggering a large indexing task; you should see the indexing threads isolated from the threads handling the UI-critical lookups.
Diagnostic Detail Needed: Are you using a custom RequestProcessor implementation or the standard API provided by the NetBeans platform? A custom implementation may allow for a PriorityBlockingQueue, which would change the recommendation.