Skip to content

Commit 40711b1

Browse files
authored
feat(process): processMemory.summarize 汇总压缩/换出内存、GPU 显存与 CPU、GPU 占用 (#45)
- 进程行新增 compressedBytes(已压缩或写到磁盘、不在 bytes 里)、gpuMemoryBytes(bytes 不含的显存)、cpuTime(微秒)与 gpuEngines(各引擎忙碌微秒) - 请求新增 sampledAt、previous 与 logicalProcessors;响应返回 baseline,宿主下次原样带回,由 Core 计算两次读取之间的 CPU、GPU 百分比 - 汇总、各类别、各条目带同样的可选数值:要么都有,要么都没有;GPU 取最忙引擎,CPU 默认 100 为一个处理器,给 logicalProcessors 时按全部处理器折算且不超过 100 - 新增共享 fixture 用例与单测,更新 rust-core-api.md
1 parent 06bc325 commit 40711b1

3 files changed

Lines changed: 1245 additions & 84 deletions

File tree

‎rust/contracts/rust-core-api.md‎

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ or removing a command fails until the table changes in the same commit.
576576
| `processLifecycle.resolve` | Decide how each process or resource of one Lithe instance ends |
577577
| `processLifecycle.inventory` | Group a process snapshot of one Lithe instance into terminals, Agent tasks and background services |
578578
| `processLifecycle.settle` | Turn confirmation answers into what ends, what is kept and the updated settings |
579-
| `processMemory.summarize` | Sum a process table's memory by part of one Lithe instance: the host, language servers, plugin services, system helpers and other child processes |
579+
| `processMemory.summarize` | Sum a process table's memory, compressed memory, graphics memory and processor and graphics use by part of one Lithe instance: the host, language servers, plugin services, system helpers and other child processes |
580580
| `markdown.render` | Renders and sanitizes shared Markdown |
581581
| `markdown.outline` | Outlines the headings of shared Markdown as a document-symbol tree |
582582
| `markdown.resolveReference` | Decides what a link or an image of a rendered Markdown document points at |
@@ -5107,12 +5107,21 @@ scope-token ownership. Fixtures live in
51075107

51085108
Fixtures live in `rust/fixtures/process-lifecycle/settle-v1.json`.
51095109

5110-
`processMemory.summarize` accepts `{ hostProcessId, processes, roles, entryLimit }`
5111-
and attributes every process the host could read to one part of the instance,
5112-
so every host shows the same numbers for the same table. Each process row is
5113-
`{ processId, parentProcessId, responsibleProcessId?, startTime?, name, bytes }`.
5114-
`bytes` is the memory the host charges to the process; every row of one request
5115-
uses the same measure. `responsibleProcessId` is the process the operating system
5110+
`processMemory.summarize` accepts `{ hostProcessId, processes, roles, entryLimit,
5111+
sampledAt?, previous?, logicalProcessors? }` and attributes every process the host
5112+
could read to one part of the instance, so every host shows the same numbers for
5113+
the same table. Each process row is `{ processId, parentProcessId,
5114+
responsibleProcessId?, startTime?, name, bytes, compressedBytes?, gpuMemoryBytes?,
5115+
cpuTime?, gpuEngines? }`. Every host reports memory the same way: `bytes` is
5116+
what is in memory, and `compressedBytes` is what the system compressed or wrote
5117+
out to disk, which `bytes` does not include. `gpuMemoryBytes` is graphics memory
5118+
charged to the process that `bytes` does not hold, such as dedicated video memory
5119+
on Windows; a host whose `bytes` already holds it leaves it out. `cpuTime` is the
5120+
processor time the process used since it started, user and system together, in
5121+
microseconds. `gpuEngines` are `{ engine, busyTime }`: the microseconds each
5122+
graphics engine was busy with the process's work, where `engine` names the same
5123+
engine for every process and table of one host and times of one name add up.
5124+
`responsibleProcessId` is the process the operating system
51165125
holds responsible, which macOS reports for XPC services. `startTime` is in
51175126
microseconds since 1970; a reported parent that started after its child is a
51185127
reused process ID and is not followed. `roles` are
@@ -5136,14 +5145,45 @@ Every process counts at most once:
51365145
- Other processes are left out. The processes of a cycle of parent links are
51375146
decided as if none of them had a parent.
51385147

5139-
It returns `{ totalBytes, categories, entries, omitted }`. `categories` lists
5148+
It returns `{ totalBytes, compressedBytes?, gpuMemoryBytes?, cpuPercent?,
5149+
gpuPercent?, categories, entries, omitted, baseline? }`. `categories` lists
51405150
`host`, `languageServer`, `pluginService`, `systemHelper` and `childProcess` in
5141-
that order, each `{ kind, bytes, processCount }`, empty ones included. `entries`
5142-
are the groups other than the host, `{ kind, name, processId, bytes,
5143-
processCount }`, largest first, with ties ordered by part, name and process ID.
5144-
`name` is the role name, else the process name, shortened to 80 characters.
5145-
`omitted` is `{ count, bytes }` of the groups past the limit. A table without the
5146-
host or with a repeated process ID is `invalid_request`. Fixtures live in
5151+
that order, each `{ kind, bytes, processCount }` with the same optional figures,
5152+
empty ones included. `entries` are the groups other than the host, `{ kind, name,
5153+
processId, bytes, processCount }` with the same optional figures, largest first by
5154+
`bytes`, with ties ordered by part, name and process ID. `name` is the role name,
5155+
else the process name, shortened to 80 characters. `omitted` is `{ count, bytes }`
5156+
of the groups past the limit.
5157+
5158+
Each optional figure is on the summary, every category and every entry, or on
5159+
none of them. `compressedBytes` and `gpuMemoryBytes` are there when a process of
5160+
the instance reported them and sum the processes that did.
5161+
5162+
Percentages measure use between two tables of one host:
5163+
5164+
- `sampledAt` is when the table was read, in microseconds of a clock that only
5165+
moves forward. A request with it gets `baseline: { sampledAt, processes }`: the
5166+
instance's processes that have `cpuTime` or `gpuEngines`, by process ID, each
5167+
`{ processId, startTime?, cpuTime?, gpuEngines? }` with one engine row per name.
5168+
The host sends it back as `previous` with its next table.
5169+
- A process is compared with the `previous` row of its process ID and start time;
5170+
a row with another start time belongs to an earlier process with the same ID.
5171+
A process the baseline does not have, such as one started since, adds nothing
5172+
until the next table. A counter lower than its baseline adds nothing.
5173+
- `cpuPercent` is there when a process of the instance has `cpuTime` in both
5174+
tables. It is the processor time used over the interval, where 100 is one
5175+
processor busy, as Activity Monitor and `top` show it. With
5176+
`logicalProcessors` it is a share of that many processors instead, as the
5177+
Windows Task Manager shows it, and at most 100.
5178+
- `gpuPercent` is there when a process of the instance has engines in both
5179+
tables. The busy times of each engine are added up over the group, and the
5180+
busiest engine's share of the interval is the percentage, at most 100. An engine
5181+
the baseline row does not list counts from zero.
5182+
- Percentages are rounded to a tenth. Without `sampledAt`, without `previous`, or
5183+
with a `sampledAt` no later than the baseline's, there are none.
5184+
5185+
A table without the host or with a repeated process ID, or a `logicalProcessors`
5186+
of 0, is `invalid_request`. Fixtures live in
51475187
`rust/fixtures/process-lifecycle/memory-summary-v1.json`.
51485188

51495189
## Local IDE capability broker

0 commit comments

Comments
 (0)