Skip to content

Report CPU time to guests - #1756

Queued
Weidong Cui (wdcui) wants to merge 5 commits into
uliteboxfrom
wdcui/ulitebox/cpu-time
Queued

Weidong Cui (wdcui) wants to merge 5 commits into
uliteboxfrom
wdcui/ulitebox/cpu-time

Conversation

@wdcui

@wdcui Weidong Cui (wdcui) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

This PR reports CPU time to guests. The platform TimeProvider gains thread and process CPU-time queries, implemented on Linux, Windows, and macOS userland, and the broker records each runner's CPU time when it exits and accumulates it up the process tree as exits are collected. The Linux shim uses these to serve CPU-time clocks (including the caller's clock_getcpuclockid/pthread_getcpuclockid clock IDs), getrusage, times, wait4 resource usage, and SIGCHLD si_utime/si_stime.

@wdcui
Weidong Cui (wdcui) force-pushed the wdcui/ulitebox/cpu-time branch 2 times, most recently from df624b1 to f5f9769 Compare October 31, 2026 18:48
Weidong Cui (wdcui) and others added 2 commits November 1, 2026 14:59
Add a platform CpuTimeProvider for thread and process CPU time, measure
each runner's CPU time when the userland broker reaps it, and account
collected children's CPU time in the broker process tree. The Linux shim
uses these for the CPU-time clocks, getrusage, times, wait4 rusage, and
SIGCHLD si_utime/si_stime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
Decode negative clock IDs, such as those from clock_getcpuclockid and
pthread_getcpuclockid, into CPU clocks, and serve those naming the
calling process or thread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
Weidong Cui (wdcui) and others added 3 commits November 1, 2026 16:01
Fold the CPU-time queries into litebox_platform's TimeProvider, with
defaults that report CPU time as unavailable, and move CpuTime next to it
so both LiteBox and broker platforms can use them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
@wdcui
Weidong Cui (wdcui) marked this pull request as ready for review November 2, 2026 01:24
@wdcui
Weidong Cui (wdcui) added this pull request to the merge queue Nov 2, 2026
Any commits made after this event will not be merged.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/method_parameter_count_changed.ron

Failed in:
  litebox_broker_core::BrokerProcess::complete_exit takes 1 parameters in /home/runner/work/litebox/litebox/target/semver-checks/git-ulitebox/b624e83c5c5d82a25106a09bb8e507b34a6566f1/litebox_broker_core/src/process.rs:949, but now takes 2 parameters in /home/runner/work/litebox/litebox/litebox_broker_core/src/process.rs:991

--- failure constructible_struct_adds_field: struct exhaustively constructible through public API adds field ---

Description:
A pub struct that could be exhaustively constructed with a literal using only public API has a new pub field, breaking existing exhaustive literals.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field ChildExit.cpu_time in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/process.rs:89
  field ChildExit.children_cpu_time in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/process.rs:92

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_variant_added.ron

Failed in:
  variant ProcessResponse:GetChildrenCpuTime in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:688
  variant ProcessRequest:GetChildrenCpuTime in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:407

--- failure copy_impl_added: type now implements Copy ---

Description:
A public type now implements Copy, causing non-move closures to capture it by reference instead of moving it.
        ref: https://github.com/rust-lang/rust/issues/100905
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/copy_impl_added.ron

Failed in:
  litebox_common_linux::ClockId in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:2351

--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
  variant SyscallRequest::Getrlimit 90 -> 92 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3251
  variant SyscallRequest::Setrlimit 91 -> 93 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3255
  variant SyscallRequest::Prlimit 92 -> 94 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3259
  variant SyscallRequest::SetTidAddress 93 -> 95 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3270
  variant SyscallRequest::Gettid 94 -> 96 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3273
  variant SyscallRequest::SetRobustList 95 -> 97 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3274
  variant SyscallRequest::GetRobustList 96 -> 98 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3277
  variant SyscallRequest::GetRandom 97 -> 99 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3282
  variant SyscallRequest::Getpid 98 -> 100 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3287
  variant SyscallRequest::Getppid 99 -> 101 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3288
  variant SyscallRequest::Setpgid 100 -> 102 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3289
  variant SyscallRequest::Getpgid 101 -> 103 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3293
  variant SyscallRequest::Getpgrp 102 -> 104 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3296
  variant SyscallRequest::Setsid 103 -> 105 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3297
  variant SyscallRequest::Getsid 104 -> 106 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3298
  variant SyscallRequest::Getuid 105 -> 107 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3301
  variant SyscallRequest::Geteuid 106 -> 108 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3302
  variant SyscallRequest::Getgid 107 -> 109 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3303
  variant SyscallRequest::Getegid 108 -> 110 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3304
  variant SyscallRequest::Sysinfo 109 -> 111 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3305
  variant SyscallRequest::CapGet 110 -> 112 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3308
  variant SyscallRequest::GetDirent64 111 -> 113 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3312
  variant SyscallRequest::SchedGetAffinity 112 -> 114 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3317
  variant SyscallRequest::SchedGetParam 113 -> 115 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3322
  variant SyscallRequest::SchedGetScheduler 114 -> 116 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3326
  variant SyscallRequest::SchedYield 115 -> 117 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3329
  variant SyscallRequest::Futex 116 -> 118 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3330
  variant SyscallRequest::Execve 117 -> 119 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3333
  variant SyscallRequest::Umask 118 -> 120 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3338
  variant SyscallRequest::Prctl 119 -> 121 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3341
  variant SyscallRequest::Alarm 120 -> 122 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3344
  variant SyscallRequest::Pause 121 -> 123 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3347
  variant SyscallRequest::RestartSyscall 122 -> 124 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3348
  variant SyscallRequest::SetITimer 123 -> 125 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3349
  variant SyscallRequest::GetITimer 124 -> 126 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3354
  variant SyscallRequest::Statx 125 -> 127 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3358
  variant SyscallRequest::TimerfdCreate 126 -> 128 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3365
  variant SyscallRequest::TimerfdSettime 127 -> 129 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3369
  variant SyscallRequest::TimerfdGettime 128 -> 130 in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:3375

--- failure enum_repr_int_removed: enum repr(u*)/repr(i*) removed ---

Description:
repr(u*) or repr(i*) was removed from an enum. This can cause its memory representation to change, breaking FFI use cases.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#repr-int-enum-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_repr_int_removed.ron

Failed in:
  enum ClockId in /home/runner/work/litebox/litebox/litebox_common_linux/src/lib.rs:2351

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/method_parameter_count_changed.ron

Failed in:
  litebox_common_linux::signal::SiginfoData::new_child takes 3 parameters in /home/runner/work/litebox/litebox/target/semver-checks/git-ulitebox/b624e83c5c5d82a25106a09bb8e507b34a6566f1/litebox_common_linux/src/signal/mod.rs:392, but now takes 5 parameters in /home/runner/work/litebox/litebox/litebox_common_linux/src/signal/mod.rs:392

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