Commits
Tarun Sukhani authored 68fc555bdbf
fix: performance — EhCacheImpl desync, TemplateLoader TOCTOU, JobsPlugin volatile fields
Cherry-picked from worktree-agent-ae649d40 (fc7b19eb7), with the following
applied:
- EhCacheImpl.java: remove synchronized from instance methods (EhCache is
thread-safe internally; synchronized was pinning virtual threads)
- TemplateLoader.java: fix check-then-act race on ConcurrentHashMap using
compute/computeIfAbsent
- JobsPlugin.java: add volatile to executor, virtualExecutor,
usingVirtualThreads fields
Deliberately not applied from the original commit:
- VirtualThreadScheduledExecutor.java: the original swapped the scheduler's
ThreadFactory from PThreadFactory to Thread.ofVirtual().factory(). This
contradicts the file's documented two-tier design ("delegates scheduling
to a small platform-thread ScheduledThreadPoolExecutor ... dispatches
actual work to virtual threads") which exists specifically to avoid
pinning a carrier thread on DelayQueue.take(). Kept the platform-thread
scheduler.
- JobsPlugin.scheduledJobs: original commit's tree had CopyOnWriteArrayList
(introduced in earlier modernization commit 264612b1d, not in this branch).
Kept ArrayList here; CopyOnWriteArrayList migration is its own decision.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>