fix: throttle job state broadcasts to reduce dashboard query load#137
Open
salvageop wants to merge 1 commit into
Open
fix: throttle job state broadcasts to reduce dashboard query load#137salvageop wants to merge 1 commit into
salvageop wants to merge 1 commit into
Conversation
Every Oban job start/stop/exception broadcast "job:state" immediately, and each broadcast makes every subscribed dashboard LiveView re-run its counts and paginated queries. With a busy download queue, an open dashboard hammered SQLite with redundant reads. Job state telemetry now routes through a small coalescing GenServer that broadcasts at most once per second (trailing edge, so the final state of a burst is always reflected). Also guard the JobTableLive subscription with connected?/1, matching HistoryTableLive, so the throwaway static-render process doesn't subscribe.
|
🐳 Image for commit fae3b6c published: |
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.
What
Telemetry.job_state_change_broadcast/4fired a"job:state"broadcast on every Oban job start/stop/exception, and each broadcast causes every subscribed LiveView (HistoryTableLive,JobTableLive) to re-run its counts + paginated queries. With a busy download queue (fast indexing every 10 minutes, several concurrent yt-dlp workers), an open dashboard hammers SQLite with redundant reads — one full refresh per job event.Fix
PinchflatWeb.JobStateThrottleGenServer: telemetry casts to it, and it broadcasts at most once per second. Trailing-edge, so the final state of a burst is always reflected within a second — the dashboard's perceived behavior is unchanged.JobTableLive.mount/3now guards its subscription withconnected?/1, matching the fix already applied toHistoryTableLivein 98d654f (the static-render process is throwaway; subscribing it is wasted work).Test note
The existing "listens for job:state change events" test only passed by accident: it asserted the test process received the broadcast, and the test process was only subscribed because the unconditional subscribe ran during the static-render pass (which executes in the test process). It now asserts the actual behavior — the view re-renders with new jobs after a broadcast.
Testing
tooling/lint_test.shgreen