rasa icon indicating copy to clipboard operation
rasa copied to clipboard

Buffered Tracker Save to Reduce I/O Bottlenecks in TrackerStore

Open ljm020133 opened this issue 6 months ago • 2 comments

Proposed changes:

  • ...

Status (please check what you already did):

  • [ ] added some tests for the functionality
  • [ ] updated the documentation
  • [ ] updated the changelog (please check changelog for instructions)
  • [ ] reformat files using 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!

ljm020133 avatar May 09 '25 19:05 ljm020133

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 09 '25 19:05 CLAassistant

  1. BufferedTrackerStore Implementation Contributor: Alisala Mwamba What to Submit: buffered_tracker_store.py

  2. Unit Test Script for Buffered Save Contributor: Fadi Masannat What to Submit: test_buffered_tracker_store.py

  3. Add logging + observability to message processing flow Contributor: Jacob Mashol What to Submit: processor.py

  4. Inline Code Comments & Documentation from rasa.core.processor.py Contributor: Jongmin Lee

  5. Inline Code Comments & Documentation Contributor: Z Harvey What to Submit: Edited code with docstrings and inline comments

  6. Reviewed code refactors and changes suggested in the essays. Contributor: Srdan Kopunovic

ljm020133 avatar May 14 '25 18:05 ljm020133