Skip to content

perf(session): optimize offline message handling with VecDeque #260

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

Merged
merged 1 commit into from
Aug 22, 2025

Conversation

bittcrafter
Copy link
Collaborator

Performance Improvements:

  • Changed offline_messages from Vec to VecDeque for efficient FIFO operations
  • Replaced pop() with pop_front() for proper queue behavior in message processing
  • Used push_back() instead of push() for correct message ordering in storage

Structural Changes:

  • Added explicit VecDeque import for clarity
  • Updated OfflineInfo struct to use VecDeque for offline_messages
  • Maintained all existing functionality with improved performance

Key Benefits:

  1. Efficiency: VecDeque provides O(1) amortized time for both ends
  2. Correctness: Ensures proper first-in-first-out delivery of offline messages
  3. Memory: Better memory utilization for queue operations
  4. Ordering: Maintains message sequence during offline storage and retrieval

The changes ensure that offline messages are processed in the correct order while improving performance for queue operations, maintaining full backward compatibility.

Performance Improvements:
- Changed offline_messages from Vec to VecDeque for efficient FIFO operations
- Replaced pop() with pop_front() for proper queue behavior in message processing
- Used push_back() instead of push() for correct message ordering in storage

Structural Changes:
- Added explicit VecDeque import for clarity
- Updated OfflineInfo struct to use VecDeque for offline_messages
- Maintained all existing functionality with improved performance

Key Benefits:
1. **Efficiency**: VecDeque provides O(1) amortized time for both ends
2. **Correctness**: Ensures proper first-in-first-out delivery of offline messages
3. **Memory**: Better memory utilization for queue operations
4. **Ordering**: Maintains message sequence during offline storage and retrieval

The changes ensure that offline messages are processed in the correct order while improving performance for queue operations, maintaining full backward compatibility.
@bittcrafter bittcrafter merged commit f430b46 into rmqtt:master Aug 22, 2025
19 of 20 checks passed
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.

1 participant