Repository navigation
The long-history drawing test and the quit test no longer fail just because the machine is busy - #305
Merged
Merged
Conversation
… it, so a busy machine can't fail it
…tarting at that moment can't keep it locked
…ads in too; the lock's docs say the copy is a Unix matter
Owner
Author
Review (
|
This was referenced Nov 29, 2026
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 changed
a_long_history_draws_only_the_rows_in_view(wasa_long_history_draws_as_fast_as_a_short_one,core/desktop/src/app/paging.rs) no longer times frames. It counts the rows built while a history of 100, then 5,000, messages loads and is first drawn, and those built in the frame after. It asserts each count for 5,000 messages is less than twice the count for 100.ROWS_BUILT, sits inHush::row(core/desktop/src/app/view.rs), the function that promises rows are "built only for the rows on screen". It is compiled only for the snapshot tests.Rowwere built for every message on each frame (the code before The desktop app pages back through older messages and moves between chats from the keyboard #189), the counts would be (236, 115) and (10,036, 5,015).core/sig-core/src/actor.rs).actor::locknow returns aFolderLock, which unlocks the file when dropped instead of only closing it. That covers every place sig-core lets go of the lock:stop,Client's drop, the relink, unlink and restore paths that hold it while they change the folder, and a core thread that panics. The types inclient.rsfollow.Why
yeson top of other builds (load average 98–111), the old test failed 2 of 8 full runs. The property worth keeping is that only the rows in view get built, and a row count measures that without a clock.quit_stops_once_and_gpuis_own_quit_after_it_ends_at_oncefailed once withAlreadyOpen, while On Windows Hush writes a small log file, panics too, since it has no console #289 was being gated. The failing line isreopen(running.rs:350).The stop wasn't late. In the unified log of the failing run (pid 81584, 22:00:28–36), the core stopped normally. Neither timeout fired (no "didn't stop in time", no extra "didn't answer quitting in time"), and there were as many "the core stopped" lines as in a passing run of the same binary (12 and 12). So the core had closed its lock before the test opened the data again, and the lock was still held anyway.
The cause: a child process holds a copy of the lock. When a program starts, the OS copies all of the parent's descriptors into it, the close-on-exec ones too, and closes those only once the program is running. A lock closed during that moment stays held by the child's copy. I wrote a probe (C, on this Mac) that takes an exclusive
flock, closes it and locks again, 20,000 times:/usr/bin/truein a loop/usr/bin/defaultsin a loopLOCK_UNbefore each closeThe tests start programs alongside it.
the_mac_apps_user_defaults_are_read_by_their_kindruns/usr/bin/defaultsthree times. It is test 288 of 402, so it runs at about the same time as the quit tests (266 to 268), and a busy machine makes each start slower. I added a thread that starts programs during the quit test and ran it under load. Once in 80 runs without the fix, the reopen found the lock held, and it was free 831 ms later.The fix is in sig-core, where the lock lives. Unlocking explicitly (
LOCK_UN) frees the lock for every copy of the descriptor at once. Without the fix, the app recovers anyway, because a later launch already waits for the data. A core opened right after a relink, unlink or restore doesn't wait, though, so the fix helps there too.How it was tested
make format && make check:cargo fmt --check: passes.cargo clippy --all-targets -q -- -D warnings: passes.cargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warnings: passes.cargo test --features hush-desktop/snapshot -q: desktop 404 passed; sig-core 554 passed, 4 ignored. This is on the merged head, after A field's caret blinks only while Hush's window is active, minimised included #304.Rowfor every message on each frame: the test failed with (236, 115) and (10,036, 5,015).a_lock_let_go_is_free_while_a_copy_of_it_lives_onkeeps a second descriptor of the lock open, as a starting program would. It failed before the fix withErr(AlreadyOpen)and passes after it.yes(one per core): 10 of 10 full runs passed at load 10–31. The binary gated before the merge also passed 10 of 10, at load 33–67.yes: in 10 full runs at load 73–128, the paging test and the quit test passed every time.app::files::window_tests::a_click_on_a_file_presses_it_and_leaves_the_keys_in_the_composer("nothing was said"). That failure was already there: I ran main's binary and this branch's one after the other at that load, and both failed it 4 of 4. Main's binary also failed the old paging test once.said(core/desktop/src/app/view.rs) gives the core 2 s of real time to answer. That is a third test a busy machine breaks, outside this issue. It is left for its own issue.AlreadyOpenwas rare even before the fix: 0 in those runs without a thread starting programs alongside. The deterministic sig-core test and the probe are the proof of the fix, not the load runs.Closes #292