Repository navigation
Conversation
The app's agent sessions need a cost that keeps counting while its window is closed, which summing CPU percent samples cannot give. The same proc_pid_rusage call that reads the footprint now also reads user plus system time, including reaped children's, so a session's finished builds still count. The kernel keeps these in Mach absolute-time units, so they are converted through mach_timebase_info (125/3 ns per tick on Apple silicon). ProcessInfo and FfiProcessInfo carry it as cpu_time_ns, None exactly when the footprint is; the CLI JSON is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156zWNYXA7UAxNLGbLUrpFx
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Tip 🎯 Customize your risk assessments
✅ Automatic approvals, with your rules
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Summary
proc_pid_rusagecall that reads the footprint now also reads user plus system time, including the children a process has reaped, so a session's finished builds still count (open question 7: include child time).proc_pid_rusagekeeps these times in Mach absolute-time units, so they are converted throughmach_timebase_info(1 ns per tick on Intel, 125/3 ns on Apple silicon), assysinfo0.32 does for the same kernel counters. The trap is recorded indocs/internals/traps.md; the glossary gains "CPU time".ProcessInfo.cpu_time_nsandFfiProcessInfo.cpu_time_ns(#[uniffi(default = None)], so existing Swift initialisers still compile) areNoneexactly when the footprint is: another user's process, or one that is gone. The CLI JSON is unchanged (serde(skip)).The app pins this commit in a separate change (plan task C2) once it is on
main.Testing
Written in a Linux cloud session, so the macOS tests have not run. This stays a draft until they pass on a Mac.
cargo fmt --all --checkcargo test --workspace --all-targets --locked: not run on macOS. On Linux,cargo test -p tiny-ffi --lockedgives 188 passed and 5 failed; the same 5 fail on9ea3e6cwithout this change (chflags,lsof, running as root).cargo test -p tiny --lockedpasses.tiny-core's own tests do not compile on Linux before or after this change (macOS-only test code). The three unit tests of the tick conversion pass.cargo clippy --workspace --all-targets --locked -- -D warnings: clean for the macOS target (--target aarch64-apple-darwin, type-checks the macOS code and tests without running them); on Linux the 7 errors are the same as on9ea3e6c.To run on a Mac, they settle the units question:
busy_child_cpu_time_grows_and_matches_ps: a busy child's time grows and matchesps -o time=and the child's owngetrusage, within 20 ms and 5%.reaped_children_count_in_cpu_time: a child that reaped a busy grandchild reads the grandchild's time too.own_process_is_readable_and_another_users_is_notandexited_child_not_yet_reaped_is_unreadable_not_zeronow cover the CPU time as well.Generated by Claude Code