fix: add rate limiting to party analyzer updates - #3728
Conversation
Introduces a 1-second interval between party analyzer updates by tracking the next allowed update time. This prevents excessive updates and improves network efficiency.
There was a problem hiding this comment.
Pull Request Overview
Adds rate limiting to party analyzer updates to prevent excessive network requests by implementing a 1-second cooldown mechanism. This ensures updates are throttled to improve network efficiency and performance.
Key changes:
- Added a member variable to track the next allowed update time
- Implemented rate limiting logic in the update function with a 1-second interval
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/server/network/protocol/protocolgame.hpp | Added member variable to track next allowed party analyzer update time |
| src/server/network/protocol/protocolgame.cpp | Implemented rate limiting logic with 1-second cooldown in update function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
This PR is stale because it has been open 45 days with no activity. |
📝 WalkthroughWalkthroughAdds a throttled, optional-forced update mechanism for party analytics: a new per-connection timestamp member prevents updates more than once per 1000ms, and updatePartyTrackerAnalyzer gained a bool force parameter to bypass the throttle when true. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/server/network/protocol/protocolgame.cpp`:
- Around line 8488-8494: The current 1s throttle using m_nextPartyAnalyzerUpdate
blocks immediate UI refreshes for explicit user actions; update the party
analyzer update path (where m_nextPartyAnalyzerUpdate and the time check are
used in protocolgame.cpp) so that user-driven events (e.g., handling
PARTYANALYZERACTION_PRICEVALUE) either pass a force flag to skip the rate-check
or reset m_nextPartyAnalyzerUpdate = 0 before calling the update routine to
guarantee an immediate refresh; also replace the literal 1000 with a named
constant (e.g., PARTY_ANALYZER_THROTTLE_MS) and document the per-connection
threading assumption near the code.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/server/network/protocol/protocolgame.cppsrc/server/network/protocol/protocolgame.hpp
🧰 Additional context used
🧬 Code graph analysis (1)
src/server/network/protocol/protocolgame.cpp (2)
src/utils/tools.cpp (2)
OTSYS_TIME(1561-1566)OTSYS_TIME(1561-1561)src/utils/tools.hpp (1)
OTSYS_TIME(167-167)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: macos-macos-debug
- GitHub Check: macos-macos-release
- GitHub Check: ubuntu-22.04-linux-release
- GitHub Check: ubuntu-22.04-linux-debug
- GitHub Check: ubuntu-24.04-linux-release
- GitHub Check: ubuntu-24.04-linux-debug
- GitHub Check: windows-2022-windows-release
- GitHub Check: build_docker_x86
- GitHub Check: build_docker_arm
🔇 Additional comments (1)
src/server/network/protocol/protocolgame.hpp (1)
560-561: LGTM!The member variable addition is well-designed:
uint64_tis appropriate for millisecond timestamp storage- Default initialization to
0ensures the first update proceeds immediately- Naming follows the
m_prefix convention used for other members likem_playerDeathTime
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
Bug Fixes: - Applied rate limiting to party tracker analyzer updates to prevent excessive updates (max ~1s). - Ensures an immediate/forced party analytics refresh after key party actions so analytics remain up-to-date.



Introduces a 1-second interval between party analyzer updates by tracking the next allowed update time. This prevents excessive updates and improves network efficiency.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.