Repository navigation
Some more cleanups & fixes - #557
Open
parenthetical wants to merge 49 commits into
Open
parenthetical wants to merge 49 commits into
parenthetical wants to merge 49 commits into
Conversation
…ightBag IntMap.size is O(n), so the code in merges comparing the number of parents (n) with the number of entries in the merge's HeightBag could be slow on wide merges, with a worst case O(n^2) if every parent changed height. Solved it structurally by changing how HeightBag works. The latter now stores the number of invalidated merge parents and the earlier comparison is no longer needed. Even non mergeInt merges are now a little bit more efficient I believe.
wrap just had a single use left
After a merge was unsubscribed from, it would still subscribe to a new parent arriving via the incremental update change event. This could cause a useless pair of subscribe and unsubscribes (unsubscribing when the GC collected the new subscription). Also removed the retained subscribe function in merge which was not needed, saving a few bytes.
`runFrame` collects the switches to reconnect before it updates merges, and reconnects them after. If a finalizer unsubscribes a switch in between, the switch would still subscribe to its new parent, and stay subscribed until the GC collected it. The old parent would also get unsubscribed twice. To fix, the switch's current parent ref now has an unsubscribed state, and runFrame skips switches in that state.
It was only used to finalize the weak invalidator when a switch is unsubscribed, so that a later hold change can't put the switch back into toReconnect. runFrame skips unsubscribed switches now, so we don't need that. Finalizing it again in the reconnect loop did nothing, since invalidate already finalizes it. Saves an IORef per switch subscription.
Focused.fans was defined but missing from the list of cases, so no benchmark measured firing through fan and fanInt. Also drop the trailing spaces from two of its names.
Fan now works like cacheEvent, where only the subscribers have a strong reference to the fan state and no finalizer is needed to allow the fan's parent and further up to be garbage collected. Also fixes a race condition between the finalizer thread and the frame-running thread, by making sure that the whole per-key subscriber map is manipulated atomically.
It's a little bit more efficient.
Root events contained races between the finalizer thread and the frame thread on the rootSubscribed map. A subscriber added during a teardown would never fire, and map updates could get lost. Map updates are now atomic and a teardown deletes only its own entry. An MVar per setup makes the setups and teardowns of a key alternate. Root events are now structured similarly to fans as well, making the code more uniform.
The newSubscriberHold, propagateSubscriberHold and getHoldEventSubscription functions were only used in initHold.
Occurrences queued before the event was torn down and set up again did not reach its new subscribers. This includes occurrences queued after the last subscriber was garbage collected and before the finalizer thread or the next subscription ran the teardown.
Contributor
|
Could you add https://github.com/obsidiansystems/style.hs while at it, please? |
fourmolu formats the code between CPP directives as separate top-level parts, so a conditional inside a declaration either fails to parse.
subrepo: subdir: "style.hs" merged: "417c71ee" upstream: origin: "git@github.com:obsidiansystems/style.hs.git" branch: "main" commit: "417c71ee" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
parenthetical
force-pushed
the
alns/2026-10-21-many-changes
branch
from
November 8, 2026 20:40
001ca4c to
93e930f
Compare
ymeister
reviewed
Nov 8, 2026
| extra-substituters = https://nixcache.reflex-frp.org | ||
| extra-trusted-public-keys = ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI= | ||
| - name: Check formatting | ||
| run: git ls-files -z '*.hs' | xargs -0 nix run ./style.hs -- --mode check |
Contributor
There was a problem hiding this comment.
IIRC, this only runs fourmolu check, not hlint
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.
No description provided.