Repository navigation
feat(macos): the Quick Look extensions run the kernel out of process (#64 part 2) - #107
Merged
Merged
Conversation
This was referenced Oct 13, 2026
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
…read (#64 PR 2) Review round 2 on #107 (the admission limit is #108, which merges first): - closing a preview releases its view controller; deinit cancels the run. ql-e2e closes a preview of a 4000-part file at 8 s: its kernel is cancelled with SIGKILL, reaped, and gone (fails without the cancel) - StepvPreviewSession: the ready rule, the 20 s ready timer, a 122 s backstop that cancels a run whose service never replies and shows why, late replies dropped once (StepvOnce, shared with the thumbnail), the mesh decoded and its scene built off the main thread; unit tests with a fake service (fail without the backstop) - test-macos.sh: the linkage check fails closed (/nonexistent fails) - run-all.sh: the wait for huge.step's kernel fails when it runs out; the deadline kill must be huge.step's own pid; services name themselves (bundle id) in their start line, as the log cannot tell the two supervisors apart by image path - docs no longer call the kernel in-process (plan.md status and risks, extension.entitlements, capi/src/lib.rs) Refs: #64
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
…a) (#108) ## #64 PR 2a: the supervisor's admission limit Refs #64. This merges **before** #107 (#64 PR 2), so `main` never ships unbounded kernel concurrency. #107 rebases onto it. ### What changes - `Admission` in `macos/Supervisor/main.swift`: each service runs at most **L = clamp(physical memory / (4 × 4096 MB), 1, cores)** kernels at once. - That's about ¼ of RAM per service, ½ across the thumbnail and preview services. - L is 1 on an 8–16 GB Mac and on CI's 7 GB runner, and 16 on sage. - Requests over L wait in a **FIFO** queue. - Their **deadline counts from submission**: queue time is spent. - A request that expires or is cancelled in the queue is **withdrawn without spawning a kernel**, and gets its normal deadline or cancelled reply. - Queueing, admission and withdrawal are logged. Each service also names itself (bundle id) and its L in its start line: the two supervisors are one binary, so the log can't tell them apart by image path. ### Tests (against main's code: the supervisor probe and harness, not the extensions) - `scripts/ql-e2e/supervisor.sh` builds a **test supervisor** (`-D STEPV_TEST_HOOKS`, never shipped) that reads L = 1 from its bundle. With it: - the second of two runs spawns only after the first has ended, checked from the log's order; - a run whose deadline passes in the queue **never spawns**. - The probe's concurrency check follows the service's logged L: at L ≥ 2 the second run finishes beside the first, at L = 1 it is served after it. ### Results (sage) - `scripts/test-macos.sh`: exit 0 (L = 16, plus the L = 1 test build). - `scripts/ql-e2e/supervisor.sh` on a copy whose supervisors are the L = 1 build (CI's case): exit 0. - Product code: +114 lines.
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
…read (#64 PR 2) Review round 2 on #107 (the admission limit is #108, which merges first): - closing a preview releases its view controller; deinit cancels the run. ql-e2e closes a preview of a 4000-part file at 8 s: its kernel is cancelled with SIGKILL, reaped, and gone (fails without the cancel) - StepvPreviewSession: the ready rule, the 20 s ready timer, a 122 s backstop that cancels a run whose service never replies and shows why, late replies dropped once (StepvOnce, shared with the thumbnail), the mesh decoded and its scene built off the main thread; unit tests with a fake service (fail without the backstop) - test-macos.sh: the linkage check fails closed (/nonexistent fails) - run-all.sh: the wait for huge.step's kernel fails when it runs out; the deadline kill must be huge.step's own pid; services name themselves (bundle id) in their start line, as the log cannot tell the two supervisors apart by image path - docs no longer call the kernel in-process (plan.md status and risks, extension.entitlements, capi/src/lib.rs) Refs: #64
gerchowl
force-pushed
the
feature/64-xpc-supervisor-2
branch
from
October 13, 2026 09:48
688855f to
5309724
Compare
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
Root cause of #107's red CI: log show --start takes whole seconds and verdicts matched by file alone, so the repeated cache-control request (served from Quick Look's cache in 7 ms) passed on the "drawn" line of the request before it, for the same file, in the same second. Reproduced 5 of 5 locally; caught 5 of 5 after. - e2elog.py: events from a request's own start on, to the microsecond; supervisor lines attributed to their service by pid from the start lines that name them. verdict.py, the huge.step deadline case (its own kernel pid, from the thumbnail service) and the closed preview use it - the closed preview is measured from the host's logged close (within 3 s), so a kill when the host quits cannot pass - the linkage check requires a Mach header and linked libraries: a text file fails it (otool exits 0 on one) - plan.md: Quick Look makes a new controller per previewed item and releases the old one (measured), so prepare is not called twice on one Refs: #64
gerchowl
added a commit
that referenced
this pull request
Oct 13, 2026
…ase holds past its deadline (#111) #113's first CI run, reproduced locally with the new diagnostics: the held run DID spawn, but drive() waited on the wrong service: a window opened at a whole second held step 1's killed instance's start line, taken for step 2's (the same window counted 11 spawns for 10). Its second run failed in ql-e2e's cache control: the same whole-second window, there fixed on #107 (e2elog.py), still on main. - supervisor.sh opens each window at a microsecond (set_start, e2elog.py) - ql-e2e.sh and verdict.py count only the events from the request's own start on (e2elog.py, as on #107) - handover: B's deadline 20 s, the test build's hold 30 s, so B's deadline passes during the hold whatever the log's latency (it once exceeded the 4 s deadline) Refs: #111
gerchowl
force-pushed
the
feature/64-xpc-supervisor-2
branch
from
November 8, 2026 16:32
5309724 to
ecb5616
Compare
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
…read (#64 PR 2) Review round 2 on #107 (the admission limit is #108, which merges first): - closing a preview releases its view controller; deinit cancels the run. ql-e2e closes a preview of a 4000-part file at 8 s: its kernel is cancelled with SIGKILL, reaped, and gone (fails without the cancel) - StepvPreviewSession: the ready rule, the 20 s ready timer, a 122 s backstop that cancels a run whose service never replies and shows why, late replies dropped once (StepvOnce, shared with the thumbnail), the mesh decoded and its scene built off the main thread; unit tests with a fake service (fail without the backstop) - test-macos.sh: the linkage check fails closed (/nonexistent fails) - run-all.sh: the wait for huge.step's kernel fails when it runs out; the deadline kill must be huge.step's own pid; services name themselves (bundle id) in their start line, as the log cannot tell the two supervisors apart by image path - docs no longer call the kernel in-process (plan.md status and risks, extension.entitlements, capi/src/lib.rs) Refs: #64
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
…ream (#64 PR 2) #107's Quick Look cases (the deadline with a thumbnail beside it, the next request, the closed preview) were written against log show and "since T" windows; #113 replaced both with one log stream, matched by identity. They now follow it: - each extension logs which run of which service took its file ("accepted: run #N (service pid P), thumbnail|preview <path>"), and runs.py reads that run's own lines from the stream, in stream order; no timestamp is compared - the concurrency check follows the service's admission limit (#108): at L >= 2 the run beside is never queued and exits before the held run's kill; at L = 1 it is queued and spawns only after that kill, if at all - a closed preview's cancel must fall between the host's logged close and its logged quit, 3 s later, so the kill at the quit cannot pass - a preview switched to another file under a live run: the old kernel goes at the switch, box.brep is shown. Quick Look makes a new controller (measured, again); should it ever reuse one, the controller cancels the session it replaces and logs it - verdict.py: a preview is ready once, on its tree before the scene (STEP) or on its mesh (IGES, BREP), in stream order - runs_test.py checks every verdict on made-up streams, a decoy service whose pid has the real one's as a prefix among them Refs: #64
This was referenced Nov 8, 2026
gerchowl
force-pushed
the
feature/64-xpc-supervisor-2
branch
from
November 8, 2026 17:33
ecb5616 to
21d8dec
Compare
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
…read (#64 PR 2) Review round 2 on #107 (the admission limit is #108, which merges first): - closing a preview releases its view controller; deinit cancels the run. ql-e2e closes a preview of a 4000-part file at 8 s: its kernel is cancelled with SIGKILL, reaped, and gone (fails without the cancel) - StepvPreviewSession: the ready rule, the 20 s ready timer, a 122 s backstop that cancels a run whose service never replies and shows why, late replies dropped once (StepvOnce, shared with the thumbnail), the mesh decoded and its scene built off the main thread; unit tests with a fake service (fail without the backstop) - test-macos.sh: the linkage check fails closed (/nonexistent fails) - run-all.sh: the wait for huge.step's kernel fails when it runs out; the deadline kill must be huge.step's own pid; services name themselves (bundle id) in their start line, as the log cannot tell the two supervisors apart by image path - docs no longer call the kernel in-process (plan.md status and risks, extension.entitlements, capi/src/lib.rs) Refs: #64
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
…ream (#64 PR 2) #107's Quick Look cases (the deadline with a thumbnail beside it, the next request, the closed preview) were written against log show and "since T" windows; #113 replaced both with one log stream, matched by identity. They now follow it: - each extension logs which run of which service took its file ("accepted: run #N (service pid P), thumbnail|preview <path>"), and runs.py reads that run's own lines from the stream, in stream order; no timestamp is compared - the concurrency check follows the service's admission limit (#108): at L >= 2 the run beside is never queued and exits before the held run's kill; at L = 1 it is queued and spawns only after that kill, if at all - a closed preview's cancel must fall between the host's logged close and its logged quit, 3 s later, so the kill at the quit cannot pass - a preview switched to another file under a live run: the old kernel goes at the switch, box.brep is shown. Quick Look makes a new controller (measured, again); should it ever reuse one, the controller cancels the session it replaces and logs it - verdict.py: a preview is ready once, on its tree before the scene (STEP) or on its mesh (IGES, BREP), in stream order - runs_test.py checks every verdict on made-up streams, a decoy service whose pid has the real one's as a prefix among them Refs: #64
gerchowl
added a commit
that referenced
this pull request
Nov 8, 2026
…s once (#64 PR 2) #107's review: cancelling a session did not stop a result it had already accepted. A finished, then the controller was reused for B while A's decode ran: A's scene was shown and logged under B, B was marked ready by A's result, and A's completion handler was overwritten and never called. - the session owns its path and Quick Look's handler. Once cancelled (the view closed, or superseded; main thread), a tree, progress, result or ready on its way is dropped and logged "stale, dropped", never shown - the handler completes exactly once per prepare: nil when ready, or CocoaError(.userCancelled) if cancelled first; each call is logged - the handler is released once called: it retains the view controller, which holds the session, and a controller kept alive past its close never cancels its run (ql-e2e's closed preview failed without this) - StepvPreviewSlot holds the controller's one preview and cancels the one a second prepare supersedes - PreviewSessionTests drives the reuse path with a fake service. Without the liveness check it fails (exit 1): A's result is shown and marks B ready - ql-e2e asserts that a closed or switched preview shows no result for the file that went, and completes its handler exactly once (runs.py gone) - plan.md: what a cancelled session guarantees for the kernel, the display and the handler Refs: #64
…64 part 2) Both extensions hand the file to their supervisor service (#98) and link no kernel: no libstepvocct, no OCCT (otool-checked in test-macos.sh). - Thumbnail: one reply with the rendered image; deadline 15 s (QL's thumbnail watchdog is reportedly ~20 s), a 17 s backstop for a service that cannot reply. - Preview: the header at once, then the assembly tree and progress as they stream, then the scene. handler(nil) once the header and tree are on screen; with no tree, on the first mesh or the failure; at the latest after 20 s (watchdog ~30 s). The run may take 120 s, and is cancelled when the view goes. - ql-e2e on the real extensions: preview and thumbnail for STEP, IGES and BREP, with the handler rule checked from the log; a thumbnail past its deadline killed with no survivor, a concurrent request beside it, and the next request with no throttle. - plan.md and CHANGELOG: the design, the deadline values and why, the limits (#92, #97, #101, macos-outer). Refs: #64
…read (#64 PR 2) Review round 2 on #107 (the admission limit is #108, which merges first): - closing a preview releases its view controller; deinit cancels the run. ql-e2e closes a preview of a 4000-part file at 8 s: its kernel is cancelled with SIGKILL, reaped, and gone (fails without the cancel) - StepvPreviewSession: the ready rule, the 20 s ready timer, a 122 s backstop that cancels a run whose service never replies and shows why, late replies dropped once (StepvOnce, shared with the thumbnail), the mesh decoded and its scene built off the main thread; unit tests with a fake service (fail without the backstop) - test-macos.sh: the linkage check fails closed (/nonexistent fails) - run-all.sh: the wait for huge.step's kernel fails when it runs out; the deadline kill must be huge.step's own pid; services name themselves (bundle id) in their start line, as the log cannot tell the two supervisors apart by image path - docs no longer call the kernel in-process (plan.md status and risks, extension.entitlements, capi/src/lib.rs) Refs: #64
… close (#64 PR 2) - the linkage check requires a Mach header and linked libraries: a text file fails it (otool -L exits 0 on one) - the ql-e2e preview host logs its close to the unified log, so the closed-preview case is measured from the close, not from the spawn - plan.md: Quick Look makes a new controller per previewed item and releases the old one (measured), so prepare is not called twice on one The log scoping this commit first carried (log show, to the microsecond) is superseded by #113's single log stream and identity matching. Refs: #64
…ream (#64 PR 2) #107's Quick Look cases (the deadline with a thumbnail beside it, the next request, the closed preview) were written against log show and "since T" windows; #113 replaced both with one log stream, matched by identity. They now follow it: - each extension logs which run of which service took its file ("accepted: run #N (service pid P), thumbnail|preview <path>"), and runs.py reads that run's own lines from the stream, in stream order; no timestamp is compared - the concurrency check follows the service's admission limit (#108): at L >= 2 the run beside is never queued and exits before the held run's kill; at L = 1 it is queued and spawns only after that kill, if at all - a closed preview's cancel must fall between the host's logged close and its logged quit, 3 s later, so the kill at the quit cannot pass - a preview switched to another file under a live run: the old kernel goes at the switch, box.brep is shown. Quick Look makes a new controller (measured, again); should it ever reuse one, the controller cancels the session it replaces and logs it - verdict.py: a preview is ready once, on its tree before the scene (STEP) or on its mesh (IGES, BREP), in stream order - runs_test.py checks every verdict on made-up streams, a decoy service whose pid has the real one's as a prefix among them Refs: #64
…s once (#64 PR 2) #107's review: cancelling a session did not stop a result it had already accepted. A finished, then the controller was reused for B while A's decode ran: A's scene was shown and logged under B, B was marked ready by A's result, and A's completion handler was overwritten and never called. - the session owns its path and Quick Look's handler. Once cancelled (the view closed, or superseded; main thread), a tree, progress, result or ready on its way is dropped and logged "stale, dropped", never shown - the handler completes exactly once per prepare: nil when ready, or CocoaError(.userCancelled) if cancelled first; each call is logged - the handler is released once called: it retains the view controller, which holds the session, and a controller kept alive past its close never cancels its run (ql-e2e's closed preview failed without this) - StepvPreviewSlot holds the controller's one preview and cancels the one a second prepare supersedes - PreviewSessionTests drives the reuse path with a fake service. Without the liveness check it fails (exit 1): A's result is shown and marks B ready - ql-e2e asserts that a closed or switched preview shows no result for the file that went, and completes its handler exactly once (runs.py gone) - plan.md: what a cancelled session guarantees for the kernel, the display and the handler Refs: #64
gerchowl
force-pushed
the
feature/64-xpc-supervisor-2
branch
from
November 8, 2026 17:42
21d8dec to
cbbe55e
Compare
… a set time (#64 PR 2) cbbe55e's macos-15 CI: the closed preview was cancelled only at the host's quit, with no completion logged. Quick Look keeps the extension's view controller while its handler is outstanding, and on the small runner the 4000-part file's tree had not come by the host's fixed 8 s close; so the controller, and its run, lived until the handler. Measured on sage: closed at 0.3 s, ready (tree) at 4.97 s, cancelled 32 ms after that. - the preview host logs its pid and closes or switches on SIGUSR1, which run-all.sh sends once the file's ready line is in the stream; it quits 3 s later, the bound the cancel must keep - a new case, closed before ready (on the file's kernel spawn): the close must come before the ready line and the cancel after it, before the quit - runs.py: first, order; cancelled bounds on any logged line - plan.md: what a preview closed before it is ready costs (until its ready, 20 s at the latest); #122 asks whether to call the handler sooner Refs: #64
4 tasks
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.
#64 part 2: the Quick Look extensions run the kernel out of process
Closes #64. Builds on #98 (part 1: the supervisor service), #103 (the kernel reads its descriptor directly) and #91.
What changes
libstepv_capi.aonly (the renderer and header reader).otool -Lshows no libstepvocct and no OCCT, andscripts/test-macos.shnow checks that. The app'sFrameworks/serves the CLI's kernel alone.handler(nil): once the header and tree are on screen. With no tree (IGES, BREP, a failed or oversized outline), on the first mesh or the failure. At the latest after 20 s (the watchdog is about 30 s; 10 s of margin).ql-e2e on the real extensions (
just ql-e2e)Every check reads #113's single
log streamand matches by identity, never by time:accepted: run #N (service pid P), thumbnail|preview <path>.scripts/ql-e2e/runs.pyreads that run's own lines and judges by stream order alone.runs_test.pychecks each verdict on made-up streams first, with a pid-prefix decoy among them.box.brepbeside it.killed (deadline), no thumbnail, its kernel gone, and the next thumbnail under 3 s.box.breponce the file is ready. The old kernel must be cancelled between the switch and the quit, and box.brep must be shown.StepvPreviewSlot):stale, dropped.nilwhen ready,CocoaError(.userCancelled)if cancelled first. It is then released, because it retains the controller.Results (head 08eb056; sage, macOS 26.4; rebased on main after #113, #81, #116 and #119)
just macos-test: exit 0. That includes the preview-session unit tests, the linkage check and the supervisor probe.(compatibility versionline. A text file fails it, and so does/nonexistent. The old check passed a text file, becauseotool -Lexits 0 on one.just ql-e2eon the product build (L = 4): exit 0, ALL PASS.deinitcancel (mutant): FAILURES. The closed and the switched preview were each cancelled only after the host quit.PreviewSessionTests): A's result arrives and its decode is still running when B supersedes it.just macos-testexit 0,just ql-e2eexit 0, ALL PASS. Closed before ready: ready (tree) at 4.47 s, then the cancel, reaped in 15.9 ms..p21), macOS preview: a mesh that fails to decode is reported as "no geometry" #121 (a mesh decode error is reported as "no geometry"). Design question: macOS preview: a preview closed before it is ready keeps its kernel until it becomes ready (≤ 20 s) #122 (call the handler sooner?).scripts/ql-e2e/supervisor.sh: exit 0.cargo fmt --check: exit 0.cargo clippy --all-targets -- -D warnings: exit 0. No kernel change.Known limits
macos-outer: the kernel's own Seatbelt profile can't nest inside the service's sandbox.macos/Shared/StepvKernel.swiftand plan.md.