Skip to content

sminos 1.46.2: daemon profile, a profile window on the live daemon - #492

Merged
SSFSKIM merged 2 commits into
mainfrom
sminos-daemon-profile
Nov 12, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
sminos-daemon-profile

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 12, 2026

Copy link
Copy Markdown
Owner

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.

  • Nothing while no profile is asked for. The verb writes a request file and nudges; each loop opens its own request file only when it sees a new nudge, which it already looks at. No new periodic read, stat or timer.
  • Older code is unharmed. No signal is sent. A process that does not know the request only ticks at the nudge; after 20 s the verb withdraws its request and says the process did not take it.
  • Nothing in it can raise into a live loop. A refusal that cannot be written goes to daemon.log; a window whose timer fails to start is rolled back.
  • The window begins after the pass the nudge brought, so the nudge's own whole look is not in it.
  • It refuses, saying why, when no daemon or no uplink runs here, when a profile is already running or waiting, and on Python older than 3.12.

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 live daemon run and 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)

… 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)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T12:20:02.103388Z 156e1ca PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +194 to +195

class Window(Home):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@SSFSKIM
SSFSKIM merged commit 8013d1c into main Nov 12, 2026
12 checks passed
@SSFSKIM
SSFSKIM deleted the sminos-daemon-profile branch November 12, 2026 12:34
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