Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3f84372
feat: major performance improvements and mailbox abstraction (v0.2.0)
claude Nov 17, 2025
fcc0efd
feat: introduce modular architecture with cajun-core and cajun-mailbo…
claude Nov 18, 2025
8532077
feat: add LMDB persistence and complete cajun-persistence module (v0.…
claude Nov 18, 2025
b30edf5
fix: correct package declarations and imports for persistence module
claude Nov 18, 2025
8f6184d
chore: add logback as testRuntimeOnly dependency to core modules
claude Nov 18, 2025
842801d
refactor: extract cluster module from lib to cajun-cluster
claude Nov 18, 2025
cdf92f1
docs: update persistence documentation with batch size performance in…
contrasam Nov 18, 2025
2c298c7
ci: add LMDB native library dependency to GitHub Actions workflows
contrasam Nov 18, 2025
9a74808
docs: remove outdated modularization and performance documentation
contrasam Nov 18, 2025
5927e07
refactor: improve mailbox error handling and use strategy pattern
claude Nov 19, 2025
8caaa3f
test: add comprehensive unit tests for mailbox implementations
claude Nov 19, 2025
124b349
refactor: reorganize imports and enhance mailbox benchmark tests
contrasam Nov 19, 2025
e8b323b
feat: add enhanced workload benchmark for mailbox implementations and…
contrasam Nov 19, 2025
bd8ce73
docs: update documentation structure and add performance benchmarking…
contrasam Nov 20, 2025
bfe2f63
chore: javadoc and warning fixes
contrasam Nov 20, 2025
ec63cae
fix: critical big on ask pattern
contrasam Nov 20, 2025
2b32d8f
fix: added extension to make tests not create temp directories in the…
contrasam Nov 20, 2025
a07eca2
feat: refactor ask pattern to a promise-based implementation, improvi…
contrasam Nov 24, 2025
2b18c68
fix: tests for AskPattern
contrasam Nov 24, 2025
1b731ec
fix: addressing review comments frpm greptileai
contrasam Nov 24, 2025
2c38650
fix: addressing older review comments from greptileai
contrasam Nov 24, 2025
1a84e3e
fix: tests and greptileai memory leak fix
contrasam Nov 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Install LMDB
run: sudo apt-get update && sudo apt-get install -y liblmdb0
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
Expand All @@ -47,6 +49,8 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Install LMDB
run: sudo apt-get update && sudo apt-get install -y liblmdb0
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ build
.env*
.env
!.env.example

# Persistence directories
cajun_persistence/
cajun-test-*/
/tmp/cajun-*

86 changes: 86 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,92 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.0] - 2025-11-23

### Changed
- **Promise-Based Ask Pattern**: Completely refactored the ask pattern from an actor-based approach to a **pure promise-based implementation** using CompletableFuture registry
- **Performance**: ~100x faster - eliminated temporary actor creation/destruction overhead (~100μs → ~1μs per request)
- **Reliability**: Zero race conditions - no thread startup timing issues
- **Simplicity**: Direct future completion instead of actor lifecycle management
- **Architecture**:
- Removed temporary "reply actor" spawning for each ask request
- Added `PendingAskRequest` record to hold futures, timeouts, and completion flags
- Added `ConcurrentHashMap<String, PendingAskRequest<?>>` registry for pending requests
- Request IDs now use `"ask-" + UUID` pattern for easy identification
- `routeMessage()` intercepts ask responses and completes futures directly
- **Cleanup**: Proper timeout handling and shutdown cleanup of pending requests
- **API**: Public API remains unchanged - transparent improvement
- **Documentation**: Updated README.md and all docs to reflect promise-based implementation

- **High-Performance Mailbox Implementations**: Refactored mailbox layer for 2-10x throughput improvement
- **New Mailbox Abstraction**: Created `Mailbox<T>` interface to decouple core from specific queue implementations
- **LinkedMailbox** (Default): Uses `LinkedBlockingQueue` - 2-3x faster than old `ResizableBlockingQueue`
- Lock-free optimizations for common cases (CAS operations)
- Bounded or unbounded capacity
- Good general-purpose performance (~100ns per operation)
- **MpscMailbox** (High-Performance): Uses JCTools `MpscUnboundedArrayQueue` - 5-10x faster
- True lock-free multi-producer, single-consumer
- Minimal allocation overhead (~20-30ns per operation)
- Optimized for high-throughput CPU-bound workloads
- **Workload-Specific Selection**: `DefaultMailboxProvider` automatically chooses optimal mailbox based on workload type
- `IO_BOUND` → LinkedMailbox (10K capacity, large buffer for bursty I/O)
- `CPU_BOUND` → MpscMailbox (unbounded, highest throughput)
- `MIXED` → LinkedMailbox (user-defined capacity)

- **Polling Optimization**: Reduced polling timeout from 100ms → 1ms
- 99% reduction in empty-queue latency
- Faster actor responsiveness
- Minimal CPU overhead (virtual threads park efficiently)
- Removed unnecessary `Thread.yield()` calls (not needed with virtual threads)

- **Logging Dependencies**: Changed SLF4J from bundled dependency to API-only dependency
- **Breaking Change**: Users must now provide their own logging implementation (e.g., Logback, Log4j2)
- SLF4J API is still used for all internal logging
- Users must add Logback (or preferred SLF4J implementation) to their project dependencies
- Example configuration files available in documentation
- Provides flexibility for users to configure logging according to their needs

### Added
- **MailboxProcessor CountDownLatch**: Added thread readiness synchronization to ensure actor threads are running before `start()` returns, reducing timing issues during actor initialization
- **Mailbox Interface**: New `com.cajunsystems.mailbox.Mailbox<T>` abstraction for pluggable mailbox strategies
- **Persistence Truncation Modes**: Added configurable journal truncation strategies for stateful actors
- **OFF**: Disable automatic truncation (journals grow indefinitely)
- **SYNC_ON_SNAPSHOT**: Truncate journals synchronously during snapshot lifecycle (default)
- Keeps configurable number of messages behind latest snapshot (default: 500)
- Maintains minimum number of recent messages per actor (default: 5,000)
- **ASYNC_DAEMON**: Truncate journals asynchronously using background daemon
- Non-blocking truncation with configurable interval (default: 5 minutes)
- Reduces impact on actor message processing performance
- Configuration via `PersistenceTruncationConfig.builder()` with fluent API
- Helps manage disk space and improve recovery time for long-running stateful actors
- **Performance Benchmarks**: Added comprehensive JMH benchmarks comparing actors vs threads vs structured concurrency
- Fair benchmark methodology (pre-created actors)
- Workload-specific performance validation
- Detailed performance analysis in `docs/performance_improvements.md`
- **Module Breakdown** (In Progress): Started modularization of the library into separate Maven artifacts
- `cajun-core`: Core actor abstractions and interfaces
- `cajun-mailbox`: Mailbox implementations (LinkedMailbox, MpscMailbox)
- `cajun-persistence`: Persistence layer with journaling and snapshots
- `cajun-cluster`: Cluster and remote actor support
- `cajun-system`: Main ActorSystem implementation (combines all modules)
- `test-utils`: Testing utilities for async actor testing
- Note: Module separation is ongoing - all functionality currently available through main `cajun` artifact

### Fixed
- **Ask Pattern Race Condition**: Eliminated race condition where reply actors might not be ready to receive responses (no longer relevant with promise-based approach)
- **Lock Contention**: Eliminated synchronized lock bottleneck in old `ResizableBlockingQueue` causing 5.5x slowdown in batch processing

### Deprecated
- **ResizableBlockingQueue**: Deprecated in favor of `LinkedMailbox` and `MpscMailbox` - still works but logs deprecation warning
- **ResizableMailboxConfig**: Still supported but logs deprecation warning

### Performance
- **Ask Pattern**: ~100x faster (100μs → 1μs per request)
- **Batch Processing**: 2-5x throughput improvement with new mailbox implementations
- **Memory**: 50% reduction in per-message overhead with MpscMailbox
- **GC Pressure**: Significantly reduced with chunked array allocation
- **Overall**: Actor overhead now <2x baseline (threads) for pre-created actors, down from 5.5x-18x

## [0.1.4] - 2025-11-01

### Added
Expand Down
Loading
Loading