Skip to content

Harden resource lifetimes and reduce renderer snapshot memory - #117

Merged
elcritch merged 5 commits into
fix/kosmo-command-mode-105-107-pt2from
fix/merenda-reliability-memory
Sep 25, 2026
Merged

elcritch merged 5 commits into
fix/kosmo-command-mode-105-107-pt2from
fix/merenda-reliability-memory

Conversation

@elcritch

@elcritch elcritch commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

URL downloads previously buffered entire bodies before enforcing size limits, unchanged views inflated queued renderer snapshots, and renderer teardown could acknowledge release before GPU work and renderer destruction finished. This change bounds asset loading, reduces incremental snapshot storage, and preserves window lifetime through renderer cleanup.

  • Stream URL assets through a 32 KiB application buffer, enforce byte/concurrency/request limits, and remove partial files on cancellation or failure.
  • Compact unchanged-view metadata: a one-view update in the 1,001-view benchmark falls from 1,145,272 to 25,296 array bytes (97.8%). This measures queued arrays, not total process RSS.
  • Restore shared test imports with a NimScript CI guard; fix container removal, tab sizing, table redraws, terminal-error dialogs, and modal cleanup. Move live terminal coverage into the integration runner.
  • Move renderer commands, snapshots, and wakeups to Sigils 0.31.0 RChan, including ownership-safe replacement and channel teardown.
  • Enable dedicated rendering under ORC by retiring source-thread cycle registrations after isolating renderer commands and before sending them. Acyclic frame snapshots do not run a collection on every submission.
  • Wait for submitted GPU work and renderer destruction before acknowledging target release. Window close and runtime replacement wait for release or completed worker cleanup, including after shutdown is requested.
  • Remove the experimental useNativeDynlib mode, dynlib staging task, sharedlib dependency feature, fallback renderer/resource paths, and conditional test exclusions. FigDraw is compiled directly into the app; the obsolete define reports a migration error.
  • Add process diagnostics, a memory benchmark, repeated two-window/five-terminal lifecycle coverage, and ARC/ORC sanitizer jobs. Update PLAN.md and document remaining cache budgets and extended soak work.

Tracks FigDraw branch fix/acyclic-render-ownership from elcritch/figdraw#96 until release 0.43.0. That dependency patch leaves two explicit acyclic markers on recursive render trees, breaks the Siwin window/callback/renderer cycle with a borrowed window, and adds GPU completion operations. Renderer and backend types remain cycle-capable.

Validated locally on macOS/arm64 with Nim 2.2.12:

  • atlas-run tests after removing dynlib support: all four runners passed, with 1,467 tests and no failures or skips.
  • ORC ownership subset with Clang AddressSanitizer/UndefinedBehaviorSanitizer: 94 tests passed with no skips. Coverage includes dedicated native Metal frames, full/incremental retained scenes, delayed renderer destruction, and exception cleanup.
  • FigDraw's focused ownership/fragment/font/Siwin suites: 79 tests passed under each of ARC and ORC, with ASan/UBSan on the ORC run.
  • The example bundle compiled, the memory benchmark passed, and shared-runner import coverage, formatting, and whitespace checks passed.

Linux/X11 sanitizer jobs are configured but were not run locally. Vulkan validation was unavailable because the local workspace lacks pkg/vulkan. Windows/X11 OS-driven close notification ordering still needs an earlier barrier in Siwin.

Depends on #114; this PR targets its branch to isolate the reliability and memory changes.

Restore shared-runner coverage and fix container removal, tab sizing, table
redraws, terminal errors, and modal cleanup. Add repeated process-resource
checks, diagnostics, an import coverage guard, and ARC/ORC sanitizer jobs.

Stream URL assets with bounded bytes, admission, and concurrency. Compact
unchanged renderer frame metadata to reduce queued incremental snapshots.
Keep native rendering on the UI thread under ORC until its cross-thread
ownership is safe.

Update PLAN.md and document measurements and remaining aggregate cache work.

Validated on macOS/arm64 with Nim 2.2.12:
- atlas-run tests: four runners and 1,463 tests passed.
- ARC and ORC ownership sanitizer subsets: 90 tests passed each.
- Example bundle compiled; memory benchmark completed.
- Import coverage, workflow syntax, formatting, and whitespace checks passed.
@elcritch
elcritch merged commit 49b04d9 into fix/kosmo-command-mode-105-107-pt2 Sep 25, 2026
@elcritch
elcritch deleted the fix/merenda-reliability-memory branch September 25, 2026 00:30
elcritch added a commit that referenced this pull request Sep 25, 2026
* Fix clipped Moe help close glyph

* Improve Kosmo Git diff review and Moe logging

* Fix Kosmo X11 Backspace and Tab text input

* Test Kosmo Return and help resize regressions

* Harden resource lifetimes and reduce renderer snapshot memory (#117)

* Harden Merenda resource lifetimes and reduce snapshot memory

Restore shared-runner coverage and fix container removal, tab sizing, table
redraws, terminal errors, and modal cleanup. Add repeated process-resource
checks, diagnostics, an import coverage guard, and ARC/ORC sanitizer jobs.

Stream URL assets with bounded bytes, admission, and concurrency. Compact
unchanged renderer frame metadata to reduce queued incremental snapshots.
Keep native rendering on the UI thread under ORC until its cross-thread
ownership is safe.

Update PLAN.md and document measurements and remaining aggregate cache work.

Validated on macOS/arm64 with Nim 2.2.12:
- atlas-run tests: four runners and 1,463 tests passed.
- ARC and ORC ownership sanitizer subsets: 90 tests passed each.
- Example bundle compiled; memory benchmark completed.
- Import coverage, workflow syntax, formatting, and whitespace checks passed.

* Convert shared test import checker to NimScript

* Restore ORC renderer threads and preserve window lifetime

* Remove experimental native dynlib support

* Focus the work plan on near-term workstreams

* Filter native control text across input backends

* Update render tests for shared glyph views

* Reuse Chronos worker and stabilize column sizing test

* Disconnect Git status proxies before teardown

* Use platform shortcut modifiers in Kosmo search test

* Use platform shortcuts in Kosmo search coverage

* Keep Kosmo shortcuts working in focused terminals

* Use platform shortcut modifiers in Kosmo tab tests

* Scope sanitizer suppressions to static font caches

* Suppress Nim ORC runtime function-type UBSan diagnostic

* Scope ORC leak checks around dependency and lifetime allocations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant