feat: add rate limited publisher#817
Open
wakonig wants to merge 2 commits into
Open
Conversation
d16074d to
681a032
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
fa2a5b5 to
eb1489a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared, rate-limited Redis pipeline publisher for device-server ophyd callbacks to coalesce high-frequency updates per topic and optionally raise a warning when input update rates exceed a threshold.
Changes:
- Added
RateLimitedPipelinePublisherbackground worker that batches Redisset/set_and_publishoperations and coalesces per-topic updates during a cooldown window. - Updated
DeviceManagerDSophyd callbacks (limits/readback/config/status/progress) to publish via the rate-limited publisher and added shutdown wiring. - Added unit tests for the new publisher and adjusted existing device-manager tests to account for the new publish path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| bec_server/bec_server/device_server/devices/rate_limited_pipeline_publisher.py | New coalescing publisher with background flush thread and optional high-update-rate warning alarm. |
| bec_server/bec_server/device_server/devices/devicemanager.py | Routes several ophyd callbacks through the new rate-limited publisher and shuts it down on manager shutdown. |
| bec_server/tests/tests_device_server/test_rate_limited_pipeline_publisher.py | New tests covering coalescing behavior, per-topic isolation, shutdown flush, and warning alarm. |
| bec_server/tests/tests_device_server/test_device_manager_ds.py | Updates progress callback test to mock the new publish mechanism; reorders file-event test block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d6df135 to
0b8640f
Compare
0b8640f to
4579c55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds rate limiting to ophyd callbacks: A shared pipeline publisher is introduced to coalesce messages during a cooldown window and ensures that the latest message is emitted afterwards. On local tests, this was running with around 300 k msgs / s.
A warning is issued if the update rate per topic is higher than 200 Hz. This should give us better debugging feedback next time we encounter "funny" ECMC problems