Reuse refresh workers and skip redundant page scans #396

Closed
Boneless-Sans wants to merge 660 commits from upstream-pr/396 into main
Boneless-Sans commented 2026-11-28 04:19:01 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Boneless-Sans on 2026-11-28T04:19:01Z.


Changes

  • Use the refresh pool’s existing worker count for indexed jobs.
  • Run single-index jobs inline and skip empty jobs without allocating.
  • Reuse the populated-page check already made under the copy lock, keeping the write journal check for all pages.

The texture-queue and per-view-heap notification changes needed for the older local renderer are already in the upstream default branch.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5536591472 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/396). Originally posted by [Boneless-Sans](https://github.com/Boneless-Sans) on 2026-11-28T04:19:01Z. --- ## Changes - Use the refresh pool’s existing worker count for indexed jobs. - Run single-index jobs inline and skip empty jobs without allocating. - Reuse the populated-page check already made under the copy lock, keeping the write journal check for all pages. The texture-queue and per-view-heap notification changes needed for the older local renderer are already in the upstream default branch.
safesearch77 commented 2026-11-28 13:27:13 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by safesearch77 on 2026-11-28T13:27:13Z.


I read this against main (fe7c6e5) and the changes look correct to me.

  • unchanged_since_copy dropping taken.iter().all(|&at| at != 0): this is redundant. CopiedPages keeps uncopied_bits set exactly when at[i] == 0, and only set() writes at. The caller's range_all_copied(from / PAGE - base, (to - 1) / PAGE - base) covers the same pages as taken = at[first - base .. ceil(to / PAGE) - base], under the same ranged != 0 || condition.
  • Small suggestion: the function is pub(crate) and now depends on that caller check. A debug_assert!(ranged != 0 || taken.iter().all(|&at| at != 0)) would keep the precondition visible without costing anything in release builds.
  • wide_each with n < 2: no behaviour change. wide() already runs a single job inline, so this saves the Arc and Box. Using workers().thread_count gives the same value as wide_threads() without calling available_parallelism on every call.

No CI run is attached yet. Since Shadow::nothing_new is on the refresh path (most refreshes there copy nothing), a before/after of the refresh time in the submitting thread's frame line would show what it is worth.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7239945538 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/396#issuecomment-7239945538). Originally posted by [safesearch77](https://github.com/safesearch77) on 2026-11-28T13:27:13Z. --- I read this against `main` (`fe7c6e5`) and the changes look correct to me. - **`unchanged_since_copy` dropping `taken.iter().all(|&at| at != 0)`:** this is redundant. `CopiedPages` keeps `uncopied_bits` set exactly when `at[i] == 0`, and only `set()` writes `at`. The caller's `range_all_copied(from / PAGE - base, (to - 1) / PAGE - base)` covers the same pages as `taken = at[first - base .. ceil(to / PAGE) - base]`, under the same `ranged != 0 ||` condition. - **Small suggestion:** the function is `pub(crate)` and now depends on that caller check. A `debug_assert!(ranged != 0 || taken.iter().all(|&at| at != 0))` would keep the precondition visible without costing anything in release builds. - **`wide_each` with `n < 2`:** no behaviour change. `wide()` already runs a single job inline, so this saves the `Arc` and `Box`. Using `workers().thread_count` gives the same value as `wide_threads()` without calling `available_parallelism` on every call. No CI run is attached yet. Since `Shadow::nothing_new` is on the refresh path (most refreshes there copy nothing), a before/after of the refresh time in the submitting thread's frame line would show what it is worth.
TaynanGT commented 2026-11-29 11:37:24 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T11:37:24Z.


Thanks for checking the caller invariant against the actual CopiedPages representation. A debug assertion documenting that precondition makes sense. I'd like the submitting-thread refresh timing measured on matched runs, with copied bytes held comparable.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7255237368 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/396#issuecomment-7255237368). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T11:37:24Z. --- Thanks for checking the caller invariant against the actual CopiedPages representation. A debug assertion documenting that precondition makes sense. I'd like the submitting-thread refresh timing measured on matched runs, with copied bytes held comparable.
TaynanGT commented 2026-11-30 17:09:39 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:09:39Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285813702 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/396#issuecomment-7285813702). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:09:39Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!396
No description provided.