You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feat]: Consider providing an Executor when calling CompletableFuture.runAsync() etc. #248
Is your feature request related to a problem? Please describe.
We currently use the plain format of the CompletableFuture.runAsync() calls, i.e. not the ones that take an Executor.
When using the plain variant, it uses ForkJoinPool.commonPool() to run these tasks.
I asked Claude about the relative merits and got the following answer:
⏺ Based on your codebase analysis, here are the pros and cons of using ForkJoinPool.commonPool() vs specifying an executor:
Using ForkJoinPool.commonPool() (no executor specified)
Pros:
Simplicity - Less code, no need to manage executor lifecycle
Resource efficiency - Shared thread pool across the JVM, good for CPU-bound tasks
Work-stealing - Efficient load balancing between threads
Cons:
Shared resource contention - All applications in the JVM compete for the same threads
No isolation - Long-running or blocking tasks can starve other operations
Limited control - Can't tune pool size, thread priorities, or naming
Debugging difficulty - Harder to trace which component is using threads
Specifying a custom executor
Pros:
Isolation - Dedicated threads prevent interference between components
Controllability - Custom pool sizing, thread naming, rejection policies
Monitoring - Easier to track resource usage per component
Blocking-safe - Can use separate pools for I/O vs CPU tasks
Cons:
Resource overhead - Multiple thread pools consume more memory
Complexity - Must manage executor lifecycle and configuration
Potential waste - Underutilized dedicated pools
Recommendations for your codebase:
Looking at your usage patterns:
JSONRPCHandler.java:246 and GrpcHandler.java:225 - These handle streaming operations and should probably use dedicated
executors to avoid blocking the common pool
DefaultRequestHandler.java:387 - Already correctly uses a custom executor
ResultAggregator.java:104 - Continuation tasks could use common pool if they're short-lived
Best practice: Use dedicated executors for I/O operations, long-running tasks, or when you need isolation. Use common pool
for short CPU-bound tasks.
Describe the solution you'd like
We should look into what Claude says and evaluate whether we ought to specify an Executor in places.
Activity
fix: Use @internal Executor instead of ForkJoinPool for event consump…
fix: Implement reference counting for EventQueue to prevent premature…
fix: Implement reference counting for EventQueue to prevent premature…