Function: instrumentGpuBuffers()
function instrumentGpuBuffers(globalScope?: unknown): GpuBufferInstrument;Defined in: src/batteries/llm/chat_common/gpu_budget.ts:187
Install an OPT-IN live GPU-buffer instrument by wrapping GPUDevice.prototype.createBuffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
globalScope? | unknown | Injectable global for tests; defaults to globalThis. |
Returns
A GpuBufferInstrument; sample() returns zeroes when WebGPU is unavailable.
Remarks
This is the packaged, productionized form of the diagnostic probe used to PROVE the ORT-web freelist high-water-mark growth. It wraps createBuffer (and the returned buffer's destroy) on the device prototype to tally live/peak GPU bytes, so an application can watch the working-set climb toward the GpuBudget ceiling and surface "you're at X of Y GiB" — turning the invisible cliff into a gauge the user can act on BEFORE the OOM.
It is purely observational and strictly opt-in: nothing in the batteries installs it. Wrapping a global prototype is intrusive, so this is never on by default — an application enables it consciously (typically only in a debug/diagnostics build). Always uninstall() when done. Returns a no-op instrument when WebGPU is unavailable (Node / no API).