Skip to content

Add configurable thread pool and virtual thread support#8

Merged
macielti merged 6 commits into
mainfrom
feature/thread-pool-and-virtual-threads
May 1, 2026
Merged

Add configurable thread pool and virtual thread support#8
macielti merged 6 commits into
mainfrom
feature/thread-pool-and-virtual-threads

Conversation

@macielti

@macielti macielti commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Expose :min-threads, :max-threads, :max-queue-size as optional [:config :service] keys with sane defaults (8/50/200)
  • Build QueuedThreadPool with BlockingArrayQueue for bounded backpressure on Java < 21 — requests beyond queue capacity are rejected instead of silently filling heap
  • Auto-detect Java 21+ and switch to VirtualThreadPool for higher throughput at lower memory cost
  • Add :use-virtual-threads config flag to opt out (defaults to true)

Test plan

  • lein test — all 11 tests pass
  • New integration tests: default thread pool config, custom thread pool config
  • Existing tests updated to reflect new config keys in response body

🤖 Generated with Claude Code

macielti and others added 6 commits April 30, 2026 23:50
- Expose :min-threads, :max-threads, :max-queue-size as optional service config keys
- Build QueuedThreadPool with BlockingArrayQueue for bounded backpressure on Java < 21
- Auto-detect Java 21+ and use VirtualThreadPool for higher throughput with less memory
- Add :use-virtual-threads config flag to opt out (defaults to true)
- Add integration tests for default and custom thread pool configuration

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Fix :idle-timeout-ms being silently ignored (wrong Pedestal key);
  now applied via container-options configurator on all connectors
- Fix thread pool also silently ignored; now passed via container-options
- Add virtual-threads-enabled-by-default-test and virtual-threads-disabled-test
  asserting Thread.currentThread().isVirtual() from inside live handlers

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Upgrade CI from Java 17 to Java 21 — required for virtual thread support
  (Thread.isVirtual() does not exist on Java 17, causing 500s in tests)
- Replace Thread.isVirtual() with class name check to avoid NoSuchMethodError
  on pre-21 JVMs and GraalVM reflection restrictions

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@macielti macielti merged commit c75d8e1 into main May 1, 2026
2 checks passed
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