feat(os): add CurrentProcess resources, processors and memory limit #263
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/252-process-resources"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #252
Seed: none - the compiler uses none of these natives, so no seed refresh is needed before or after this lands.
CurrentProcess.resources(),processors(),memoryLimit()and theProcessResourcesrecord (std/os), with per-system implementations for Linux (getrusage, /proc/self/status, affinity + cgroup v1/v2 CPU quota and memory limit), macOS (getrusage, task_info, hw.ncpu, no limit) and Windows (GetProcessTimes, GetProcessMemoryInfo, affinity/active processors + job CPU rate, job memory limit). FreeBSD answers Unsupported until its slice, the browser always.compiler/src/backend/c/natives.trb, runtime code inruntime/os/{posix,linux,macos,windows}.c.std/os/tests/resources.test.trb(cgroup files, /proc status, ru_maxrss units), live checks instd/os/tests/process.test.trb, conformance casetests/conformance/process-resources.docs/standard-library/os.md,docs/design/OS.md(section 7 table, how the resources landed).Note: no local
torbor C compiler was available, soruntime/include/torb_natives.h,runtime/machine_natives.cand the skills mirrorskills/torbscript-standard-library/references/standard-library/os.mdwere regenerated by hand following the generators' output format; CI'sdocs skill --checkand the natives check verify them. pdisc refresh does not apply:docs/andskills/are outside the pdisc scope. Nothing was built or run locally; CI is the gate.CI red on
559056e:ci / tier A (linux-x64)(and sogates), two red gates (run 609):format --check:std/os/tests/resources.test.trbwould change (1 of 1207 files). Run the formatter on that file.test compiler/tests (native):A keystroke in a body keeps the sites and the index of every other module > the first keystroke builds them for every module, ...fails withAssertion failed: runs.length() == 2atcompiler/tests/language-server.test.trb:636. This is in the language-server tests, which this diff does not touch; check whether it is a flake or main-red (re-run once / compare with main) before changing anything.No review yet - my request stays pending and the next CI run brings me back.
Pushed
a0b8501:std/os/tests/resources.test.trblaid out the waytorb formatdoes (therootslist joins, the over-longuseis split in two). The language-server failure (compiler/tests/language-server.test.trb:636,runs.length() == 2) is in code this diff does not touch, and main at9ea9bb2(this PR's parent) is green, so I treat it as a flake for now; the CI run on the new head decides. If it fails again I will investigate it on this branch.CI red on
a0b8501: two gates (run 577 of theciworkflow), both caused by this PR:ci / commit messages:a0b8501d: not a Conventional Commit: style(os): lay out resources.test.trb the way torb format does.styleis not an allowed type (feat fix perf refactor docs test build ci chore revert). Reword that commit (e.g.chore(os): ...) or fold it into the first commit with a fixup/squash, and force-push.ci / tier A (linux-x64)->format --check:./std/os/tests/resources.test.trbstill "would change" (1 of 1207 files), so the layout fix ina0b8501did not reach the formatter's output. Run the repo'storb formaton that file (not a hand layout) and commit the result.The language-server assertion from the previous run did not recur, so it was a flake. Everything else (bootstrap, tier B, tools, same-C, playground, extension, pdisc) is green. Once CI is green on the new head my review runs again.
a0b8501d540a1a03f04dPushed
0a1a03f: thestyle(os)commit is folded into the feature commit (both commits are Conventional now), andstd/os/tests/resources.test.trbis the output oftorb formatitself (a torb from the host, run inside the project): a call with arguments is written without parentheses, e.g.cgroupDirectories text, "memory".torb format --checkon the file is clean after the change. The language-server flake did not recur, as noted.Checklist (head
0a1a03f, CI green):resources.test.trb: ru_maxrss unit, VmRSS, cgroup v1/v2 membership, cpu.max/quota, memory.max incl. v1 "unlimited"), live checks inprocess.test.trb, conformanceprocess-resources.rate >> 16= MaxRate) and job memory limits look right; peak is clamped to >= resident.docs/standard-library/os.md,docs/design/OS.mdand the skills mirror updated; natives header/table in sync (natives check green).natives.trb, no new boundary.Non-blocking:
runtime/os/windows.c,macos.c) and their tests are not exercised on PR CI (those tiers are skipped here), so the first real build/run of that code is on main; watch the post-merge run.CurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252