@@ -15,16 +15,31 @@ Cajun comes with sensible defaults optimized for 99% of use cases. **You don't n
1515
1616### Thread Pools
1717
18- ** Default: Virtual Threads**
18+ ** Default: Virtual Threads (I/O-Optimized) **
1919
2020Cajun uses Java 21+ virtual threads by default, providing optimal performance for I/O-bound workloads.
2121
2222``` java
23- // Uses virtual threads automatically
23+ // Uses virtual threads automatically (default)
2424Pid actor = system. actorOf(MyHandler . class). spawn();
25+
26+ // Explicitly optimize for workload type
27+ ThreadPoolFactory ioOptimized = new ThreadPoolFactory ()
28+ .optimizeFor(WorkloadType . IO_BOUND ); // Virtual threads (default)
29+
30+ ThreadPoolFactory cpuOptimized = new ThreadPoolFactory ()
31+ .optimizeFor(WorkloadType . CPU_BOUND ); // Fixed platform thread pool
32+
33+ ThreadPoolFactory mixedOptimized = new ThreadPoolFactory ()
34+ .optimizeFor(WorkloadType . MIXED ); // Work-stealing pool
35+
36+ // Apply to specific actors
37+ Pid cpuActor = system. actorOf(ComputeHandler . class)
38+ .withThreadPoolFactory(cpuOptimized)
39+ .spawn();
2540```
2641
27- ** Why virtual threads?**
42+ ** Why virtual threads by default ?**
2843- Minimal overhead for I/O operations (0.02%)
2944- Support thousands of concurrent actors
3045- Natural blocking code without callbacks
@@ -156,7 +171,7 @@ See [Actor ID Strategies](/docs/core-features/actor-id-strategies) for advanced
156171
157172| Component | Default | Configurable | When to Change |
158173| -----------| ---------| --------------| ----------------|
159- | ** Thread Pool** | Virtual Threads | ✅ Yes | CPU-bound workloads may benefit from platform threads |
174+ | ** Thread Pool** | Virtual Threads (IO_BOUND) | ✅ Yes | Use CPU_BOUND or MIXED workload types for different performance characteristics |
160175| ** Mailbox** | LinkedMailbox (10k capacity) | ✅ Yes | High-throughput CPU-bound workloads may benefit from MpscMailbox |
161176| ** Batch Size** | 10 messages | ✅ Yes | Tune for latency vs throughput tradeoff |
162177| ** Persistence** | Filesystem | ✅ Yes | Use LMDB for high-performance production workloads |
0 commit comments