Buffered Tracker Save to Reduce I/O Bottlenecks in TrackerStore #13123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes:
Status (please check what you already did):
black
(please check Readme for instructions)Summary
This PR introduces a new BufferedTrackerStore implementation that improves Rasa's runtime performance under high concurrency by reducing synchronous I/O operations during conversation state updates. Instead of persisting the tracker after every individual event, this version batches events and flushes them after a configurable threshold, significantly lowering write frequency.
Key Changes
New Feature – BufferedTrackerStore
Buffers tracker events in memory and flushes them in batches.
Configurable flush_interval controls when persistence occurs.
Maintains conversation consistency while improving write efficiency.
Unit Tests (test_buffered_tracker_store.py)
Verifies buffering logic, flush behavior, and consistency after updates.
Demonstrates correct integration with DialogueStateTracker.
Runtime Logging for Message Processing
Adds timing logs to rasa/core/processor.py to measure per-message latency.
Supports better observability and diagnostics in production environments.
Code Comments & Docs
In-line documentation and docstrings explain the rationale and functionality.
Helpful for maintainers, reviewers, and future contributors.
Why This Matters
Rasa currently persists tracker state immediately after each event, which can become a bottleneck under high load — especially with a Redis or SQL backend. This refactor:
Reduces I/O pressure on the TrackerStore
Maintains event ordering and consistency
Improves system scalability in high-concurrency deployments
QA Evidence
Unit tests pass locally and confirm batching behavior
Sample test script logs demonstrate flush intervals working as expected
Presented and documented as part of our runtime architecture analysis (slides and PDF available upon request)
Follow-Up
We’re happy to address review feedback or modify the buffer behavior based on Rasa’s long-term architecture goals. If this feature aligns with the roadmap, we would also be open to submitting follow-up improvements (e.g., state snapshotting, async flushing).
Thank you for reviewing our contribution — we’re excited to support the Rasa community!