Skip to content

Add BatchStorer for batched persistence with robust features#254

Merged
fh-ms merged 36 commits intomainfrom
batch-storer
Apr 15, 2026
Merged

Add BatchStorer for batched persistence with robust features#254
fh-ms merged 36 commits intomainfrom
batch-storer

Conversation

@fh-ms
Copy link
Copy Markdown
Contributor

@fh-ms fh-ms commented Apr 13, 2026

Summary

This pull request introduces the BatchStorer utility, designed to efficiently manage batched persistence operations. Key features include:

  • Background flush scheduler for automatic persistence of batches.
  • Thread-safe methods to ensure safe concurrent usage.
  • Optimized flushing, capacity handling, and auto-closing functionality.
  • Documentation enhancements explaining functionality, usage, synchronization, and resource management.

Changes

  • Added BatchStorer utility for managing batching of persistence operations.
  • Introduced a background flush scheduler to offload persistence tasks and ensure timely flushing.
  • Made methods of BatchStorer thread-safe to prevent concurrent modification issues.
  • Optimized BatchStorer behavior, including auto-closing and capacity controls.
  • Improved documentation for BatchStorer, focusing on use cases and implementation details.
  • Updated initialization logic by removing redundant checks and setting lastFlush with a timestamp.

Notes

No breaking changes are introduced with this pull request. Existing functionality remains unaffected by the addition.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new BatchStorer utility (Storer decorator) to batch persistence commits, with configurable flush triggering (size/time) and a scheduled background flush check to improve throughput for write-heavy workloads.

Changes:

  • Introduces BatchStorer interface and default implementation that wraps a Storer and batches commits.
  • Adds Controller helpers to trigger flushes based on time, size, or both.
  • Adds a scheduled background flush mechanism and AutoCloseable lifecycle management.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fh-ms added 2 commits April 13, 2026 14:26
…accuracy and enhance thread-safety in synchronization and shutdown logic.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fh-ms fh-ms requested a review from zdenek-jonas April 13, 2026 13:52
This change restructures the BatchStorer component by relocating it within the `types` package, simplifying its interface, and integrating new lifecycle management features. Added support for batch-storing creation methods in PersistenceManager and related classes, enabling easier control of store operations during write-heavy scenarios.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…dation, enhance synchronization, and improve lifecycle handling across persistence classes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fh-ms added 5 commits April 14, 2026 15:34
…naryStorer`

Introduce tracking of the maximum byte count per channel and implement safety flush logic to prevent exceeding 2 GB per channel. Add related methods in `ChunksBuffer` and `BinaryStorer`, ensuring proper size-based flush decisions.
…hen writes are disabled, ensuring compliance with the write-disable contract.
… improve thread safety and prevent deadlocks.

- Anti-pattern removal: Default's concurrency design explicitly warns against using the storer instance as a monitor because "outside logic could lock the storer first, reversing the lock order." Every synchronized method modifier in Batching used the storer instance (this) as the monitor — exactly this anti-pattern.
- Consistent lock ordering: By using this.head (Default's designated internal mutex), Batching now follows the same this.head → objectRegistry lock ordering that Default established. The ensureObjectId* calls acquire objectRegistry and call back to this.head reentrantly (same thread), which is safe.
- Serialization preserved: All Batching entry points still serialize through this.head, so only one thread at a time can enter ensureObjectId* or processItems, preventing the cross-thread head ↔ objectRegistry deadlock.
- Added a block comment on the Batching class explaining the locking rationale.
…ush()` after storing to match `internalStore` logic.
…Flush()` after storing to align with `internalStore` logic.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread serializer/src/main/java/org/eclipse/serializer/Serializer.java
fh-ms added 4 commits April 15, 2026 07:51
- Introduced a `HashMapIdId` utility for fast `long` to `long` mappings without boxing overhead.
- Enhanced `ChunksBuffer` and `ChunksBufferByteReversing` to enable entity deduplication, leveraging `HashMapIdId` to avoid redundant storage.
- Added logic to compact duplicate entities during buffer completion, reducing memory usage and improving efficiency.
- Updated `BinaryStorer` to integrate deduplication support with configurable behavior.
…n thread leaks on invalid `checkInterval` values.
…plicitly passed root instances and improving flush consistency.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fh-ms added 2 commits April 15, 2026 10:22
…ency design, lock ordering, and deadlock prevention logic.
…ion and hide implementation details

- Introduced `BatchStorer.Builder` for configuring `maxSize`, `flushCycle`, and `checkInterval` with a fluent API.
- Added `Persister.batchStorerBuilder()` method for streamlined instantiation.
- Updated usage examples to reflect the new builder pattern.
- Enforced contract validation to ensure at least one threshold (`maxSize` or `flushCycle`) is configured before building.
@fh-ms fh-ms merged commit bae54e1 into main Apr 15, 2026
17 checks passed
@fh-ms fh-ms deleted the batch-storer branch April 15, 2026 13:42
@fh-ms fh-ms added this to the 4.1.0 milestone Apr 16, 2026
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.

3 participants