Coalesce reload broadcasts within a quiet window#116
Open
joeljunstrom wants to merge 1 commit into
Open
Conversation
Listen + macOS fsevents commonly fires several writes for a single logical change: esbuild rewriting a bundle plus its sourcemap, editors performing atomic-rename saves, asset pipelines touching siblings. Each write currently flows through `Hotwire::Spark::Change#broadcast` and reaches the browser as a separate reload frame, producing visible flicker and redundant work. This behaviour / issue becomes apperant when running Falcon in development due to the increased concurrency. Routes broadcasts through `Hotwire::Spark::Debouncer`, a trailing-edge debouncer keyed on `[action, canonical_changed_path]`. Each event extends a quiet-window deadline; once no event has arrived for `debounce_window` seconds (default 0.1), pending entries flush as one broadcast per key. The shared state is mutex-guarded; the actual broadcast runs outside the lock so ActionCable latency does not serialize incoming watcher events. Per-block rescue keeps one failing broadcast from dropping siblings in the same flush.
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.
Listen + macOS fsevents commonly fires several writes for a single logical change: esbuild rewriting a bundle plus its sourcemap, editors performing atomic-rename saves, asset pipelines touching siblings. Each write currently flows through
Hotwire::Spark::Change#broadcastand reaches the browser as a separate reload frame, producing visible flicker and redundant work.This behaviour / issue becomes apperant when running Falcon in development due to the increased concurrency.
Routes broadcasts through
Hotwire::Spark::Debouncer, a trailing-edge debouncer keyed on[action, canonical_changed_path]. Each event extends a quiet-window deadline; once no event has arrived fordebounce_windowseconds (default 0.1), pending entries flush as one broadcast per key. The shared state is mutex-guarded; the actual broadcast runs outside the lock so ActionCable latency does not serialize incoming watcher events. Per-block rescue keeps one failing broadcast from dropping siblings in the same flush.This is part of an ongoing effort to make rails development be as nice as usual when using Falcon / fiber concurrency in local development.
Connection#closeanycable/actioncable-next#17Note that #109 is required in order for Spark to work under falcon