I was looking for places where Java 21 virtual threads might fit, since
they are intended for blocking / I/O-heavy work. BatchScanner seemed like a
candidate because it can issue many concurrent RPC-backed lookup tasks and
currently uses a platform-thread pool.

I tried a small local prototype that switches the BatchScanner query
executor to virtual threads:

if (Boolean.getBoolean("accumulo.batch.scanner.virtualThreads.enabled")) {
   queryThreadPool =
context.threadPools().createVirtualThreadExecutor(poolName);
} else {
   queryThreadPool
= 
context.threadPools().getPoolBuilder(poolName).numCoreThreads(numQueryThreads).build();
}

The prototype keeps the existing numQueryThreads behavior with a semaphore
around query task execution.

I tested this with an Accumulo JShell script against a local cluster with 4
tservers. These were immediate BatchScanner scans. The script creates a
100k-row table with 100 splits, builds 10k ranges, and runs 16 concurrent
BatchScanners with 128 scan threads. To reduce order effects, it runs full
blocks in this order: virtual, platform, virtual, platform.

Latest local summary:

platform: avg wall ~404 ms, avg throughput ~396k entries/sec, max peak
threads 1664
virtual:  avg wall ~374 ms, avg throughput ~526k entries/sec, max peak
threads 297

So the wall-time improvement in this more controlled run was modest
(~1.08x), but peak platform thread usage dropped substantially. Earlier
less-controlled runs showed larger wall-time wins, so I think the
performance result is workload/order sensitive.

One caveat: Accumulo currently requires JDK 21 to build, but still compiles
with Java 17 source/API compatibility, so my prototype uses reflection for
the virtual-thread APIs. If/when the source/API level moves to 21, that
code could be much simpler.

I’m curious what others think:
- Is BatchScanner worth exploring further as a virtual-thread use case?
- Is reducing client platform-thread pressure enough to justify continued
investigation?
- Are there other Accumulo code paths that would be good candidates for
virtual threads?

I can work on sprucing up the demo and push it to a branch if anyone is
interested in taking a look at the demo code.

Reply via email to