Skip to content

perf: rewrite five runtime Python helpers in C99 - #315

Open
tcballard wants to merge 1 commit into
OrchardLinux:mainfrom
tcballard:pr/c-runtime-helpers
Open

tcballard wants to merge 1 commit into
OrchardLinux:mainfrom
tcballard:pr/c-runtime-helpers

Conversation

@tcballard

Copy link
Copy Markdown
Contributor

Summary

Following #229 (rotate-output.c) and #230 (auto-brightness.c), rewrite five frequently invoked on-device Python helpers into small, dependency-free C99 binaries (-O2 -Wall -Wextra -Werror -std=c99) to eliminate Python interpreter RSS spikes (~20 MiB → <2 MiB) and cold-start lag (~150–400 ms → <5 ms) on 1 GiB devices:

  • omarchy-desktop-ready (desktop/configuration/desktop-ready.c) — runs at login and PIN screen readiness (/usr/libexec/omarchy-desktop-ready).
  • omarchy-rotation-lock (desktop/configuration/rotation-lock.c) — toggled from the Display panel and read by the rotation daemon (/usr/bin/omarchy-rotation-lock).
  • omarchy-launcher-recent-files (desktop/configuration/launcher-recent-files.c) — parses recently-used.xbel and queries xdg-mime when opening the app launcher (/usr/bin/omarchy-launcher-recent-files).
  • omarchy-render-labwc-theme (desktop/configuration/render-labwc-theme.c) & omarchy-render-labwc-buttons (desktop/configuration/render-labwc-buttons.c) — run on first boot (first-theme) and every theme switch (omarchy-theme-set), eliminating 2 Python spawns per theme switch.

Verification

  • All 5 binaries compile cleanly with -O2 -Wall -Wextra -Werror -std=c99 on both host x86_64 and aarch64-linux-gnu-gcc (~70 KiB unstripped each, zero external library dependencies).
  • Added tests/test_c_runtime_helpers.py covering all 5 helpers; test_c_runtime_helpers.py, test_sudo_policy.py, test_package.py, test_package_staging.py, test_idle_wakeups.py, test_kde_theme.py, and test_upstream_gtk_theme.py all pass (38/38).

Assisted-by: LLM

Replace five frequently invoked on-device Python scripts with small,
dependency-free C99 binaries (-Wall -Wextra -Werror -std=c99) to cut
RSS spikes (~20 MiB -> <2 MiB) and cold-start latency (~150-400 ms ->
<5 ms) on 1 GiB devices:

- omarchy-desktop-ready (desktop/configuration/desktop-ready.c):
  runs at login and PIN screen readiness.
- omarchy-rotation-lock (desktop/configuration/rotation-lock.c):
  toggled from the Display panel and read by the rotation daemon.
- omarchy-launcher-recent-files (desktop/configuration/launcher-recent-files.c):
  runs when opening the app launcher to parse recently-used.xbel.
- omarchy-render-labwc-theme & omarchy-render-labwc-buttons
  (desktop/configuration/render-labwc-{theme,buttons}.c):
  run on first boot and every theme switch.

Add unit tests in tests/test_c_runtime_helpers.py verifying strict C99
compilation and functional parity, and wire all five into Makefile,
desktop/install-tree, and tests/package_tree.py.

Assisted-by: LLM
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