Repository navigation
sminos 1.46.2: daemon profile, a profile window on the live daemon - #492
Conversation
… daemon run `sminos daemon profile [--seconds S] [--of uplink|run]` has the running process profile itself (cProfile, every thread on Python 3.12+) and prints its CPU over the window, its calls a second, its file calls' counts and the functions with the most time of their own. The request is a file under daemon/ that rides the nudge both loops already watch: a loop looks for it only at a new nudge, so an idle loop reads nothing more; a process on older code ticks once and the verb withdraws the request and says it was not taken. The profile is kept at mode 0600 and holds names and counts only. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…ined in the loop (review) - The verb creates its request exclusively (temp file linked into place), refuses when another profile of the same process is already being asked for (a stale one is replaced), counts it taken once the file no longer holds its id, and withdraws only its own (moved aside first, another's put back). - Nothing in noticed/after_pass raises into a loop: a refusal that cannot be written, or a request that cannot be read, is a daemon.log line. - A start that fails after cProfile is enabled disables it and clears the running window before the refusal. - The table and the docstring say own time is approximate while threads overlap (one profiler stack serves every thread); counts are exact. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 156e1ca1f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| class Window(Home): |
There was a problem hiding this comment.
Gate successful-profile tests on Python 3.12 or later
On Python 3.10 or 3.11, which remain supported by sminos/skills/sminos/references/setup.md, the daemon correctly refuses profiling, but these tests unconditionally expect successful profile files. I reproduced a missing .prof error and an incorrect refusal assertion on Python 3.11.15. Since run-sminos-tests.sh now runs this module unconditionally, the sminos gate fails on supported interpreters. Skip only the tests requiring successful profiling below 3.12, while retaining request-handling tests and testing the older-interpreter refusal.
Useful? React with 👍 / 👎.
Why
The sminos daemon's idle cost has been cut by hand three times (2026-10-28 twice, 2026-11-11), and each time the work was slowed by the same thing: a live Python daemon could not be profiled at the Python level on the machines it runs on. A native sampler shows interpreter frames only, a file-call trace needs a privilege not every machine grants, and an attaching profiler needs root. Today a bench reproduces one machine's cost and not another's, and nothing on that machine can show why.
What changes
sminos daemon profile [--seconds S] [--of uplink|run](default: the uplink, 20 s). The named process profiles itself for S seconds and the verb prints where its time went: the functions with the most time of their own, the counts of the file calls (stat,lstat,open,listdir,scandir,readlink), the calls a second, and the process's CPU over the window. The profile and a summary are written under the daemon's directory, mode 0600, the newest five of each process kept. They hold function names and counts only.daemon.log; a window whose timer fails to start is rolled back.On Python 3.12 and later cProfile sees every thread with one stack, so a function's own time is approximate while threads overlap; call counts are exact. The table's header says so.
Tests
sminos/tests/test_daemon_profile.py(20 tests, named in the suite's core part): an un-nudged tick opens no profile file; a nudged tick looks once, at its own request only; the run loop's watch looks only at a new nudge; a window sees a thread other than the one that began it; both files are 0600 and the dump holds no argument string; a second request while one runs or waits is refused; a stale or malformed request is removed; a withdrawal removes only its own request; a write that fails and a timer that fails to start are contained; a holder of the lock on older code is told "did not take", stays alive and has its request withdrawn; the livedaemon runand its uplink each profile themselves and keep running.Reviewed once at the medium rung; its four findings are fixed in the second commit. One small race is left for the debt list: a loop that reads a request and then unlinks it could remove a request another verb created in that instant, and that verb would report that no profile came back.
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)