Skip to content

Buffered Tracker Save to Reduce I/O Bottlenecks in TrackerStore #13123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: 3.6.x
Choose a base branch
from

Conversation

ljm020133
Copy link

@ljm020133 ljm020133 commented May 9, 2025

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!

@CLAassistant
Copy link

CLAassistant commented May 9, 2025

CLA assistant check
All committers have signed the CLA.

@ljm020133 ljm020133 requested a review from a team as a code owner May 14, 2025 17:59
@ljm020133
Copy link
Author

  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

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.

4 participants