Skip to content

perf(engine): make I/O executor model configurable, default to virtua…#220

Open
neuralasmi wants to merge 1 commit into
Netflix:mainfrom
neuralasmi:feat/io-virtual-thread-refactor
Open

perf(engine): make I/O executor model configurable, default to virtua…#220
neuralasmi wants to merge 1 commit into
Netflix:mainfrom
neuralasmi:feat/io-virtual-thread-refactor

Conversation

@neuralasmi

@neuralasmi neuralasmi commented Jun 12, 2026

Copy link
Copy Markdown

MaestroParamExtensionRepo used a hard-coded fixed thread pool of 3 threads (Executors.newFixedThreadPool(THREAD_NUM)) to fan out JDBC and signal lookups. This limited concurrent in-flight I/O calls across the entire engine.

The fixed 3‑thread cap created an unnecessary throughput bottleneck for I/O‑bound operations, increasing latency and underutilising resources when the engine could otherwise handle more parallelism.

  • Replaces the hard‑coded pool with a configurable executor built by the new EngineExecutors factory.
  • The factory chooses between Java 21 virtual threads (Executors.newThreadPerTaskExecutor) and a bounded platform‑thread pool based on maestro.threading.* configuration. Virtual threads are the default; PLATFORM remains available as a one‑line rollback.
  • The repository now owns the executor lifecycle: constructed in initialize(), shut down with a 5‑second grace period in shutdown(), and passed to MaestroParamExtension via constructor injection.
  • A backward‑compatible 3‑arg constructor preserves the existing public surface for tests and downstream consumers, defaulting to virtual threads.
  • No new synchronized blocks were introduced, and none existed in the changed I/O path, avoiding the known virtual‑thread pinning failure mode.

Summary of changes

  • Added EngineExecutors factory with configuration keys maestro.threading.model (VIRTUAL or PLATFORM) and optional pool sizing.
  • Refactored MaestroParamExtensionRepo to use the configurable executor instead of the fixed 3‑thread pool.
  • Injected executor lifecycle into MaestroParamExtension.
  • Added EngineExecutorsTest to verify virtual threads complete 16 concurrent 100 ms I/O tasks in ≈100 ms (vs ≈800 ms on a 2‑thread platform pool) and confirm created threads are virtual.
  • Updated shutdown logic to gracefully terminate the executor with a 5 second timeout.

…l threads

MaestroParamExtensionRepo previously hard-coded a 3-thread fixed pool
(\Executors.newFixedThreadPool(THREAD_NUM)\) to fan out JDBC and signal
lookups. That cap was a hard ceiling on concurrent in-flight I/O calls
across the whole engine.

This change replaces the hard-coded pool with a configurable executor
built by the new \EngineExecutors\ factory. The factory selects between
Java 21 virtual threads (\Executors.newThreadPerTaskExecutor\) and a
bounded platform-thread pool based on the new
\maestro.threading.*\ configuration. Virtual threads are the default;
\PLATFORM\ is preserved as a one-line rollback target if a regression is
observed in production.

The repository now owns the executor lifecycle (constructed in
\initialize()\, shut down with a 5s grace period in \shutdown()\) and
threads the executor through to \MaestroParamExtension\ via constructor
injection. A backward-compatible 3-arg constructor preserves the existing
public surface for tests and downstream consumers, defaulting to virtual
threads.

No new \synchronized\ blocks were introduced and none existed in the
I/O path under change, so the documented virtual-thread pinning failure
mode does not apply to this refactor. A new test
(\EngineExecutorsTest\) empirically demonstrates the win: 16
concurrent 100 ms I/O-style tasks complete in ~100 ms with virtual
threads (vs ~800 ms on a 2-thread platform pool) and verifies that the
created threads are actually virtual.

Co-authored-by: Netflix Maestro Maintainers <maestro-dev@netflix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant