Skip to content

3D engine that AI agents drive

Drop the pipeline cache field and the unmerged Cook pin (#1949)

Nguyen Xuan Anf895e37cc21f
diff --git a/changes/1949.md b/changes/1949.md
index ad24aed6..ce7ac8e4 100644
--- a/changes/1949.md
+++ b/changes/1949.md
@@ -1 +1 @@
-- A native render reports its kernel compile apart from trace time (`gpuTraceSeconds`, `pipelineCache`, and a `kernelCompileNote` when the compile took over a second), and Cook keeps compiled kernels in an on-disk pipeline cache so a second process with the same scene variant skips the compile.
+- A native render reports its kernel compile apart from trace time: `gpuTraceSeconds` is the trace, and a compile over one second adds a `kernelCompileNote`.
diff --git a/docs/agent-render-jobs.md b/docs/agent-render-jobs.md
index 0face4fa..99845ca9 100644
--- a/docs/agent-render-jobs.md
+++ b/docs/agent-render-jobs.md
@@ -192,7 +192,7 @@ An `image`, `stills` or `video` job can ask for the offline [path tracer](https:
Every field after `type` is optional. `backend` is `cpu` (the default, byte-identical on SwiftShader smokes), `gpu`, which traces in a WebGL2 shader and needs a runtime started on the GPU backend (a `--backend cpu` runtime refuses it), or `native`, which traces on hardware ray queries (Vulkan) through the optional `@codepawlhq/cook` package. A native job exports the scene from the job page, traces it in the job runner with the Cycles-matching kernel (`JS67_NATIVE_KERNEL=legacy` keeps the older one), then denoises (OIDN runs on a device kept alive between frames when the OIDN library is installed, so only the first frame pays for the device and the filter commit; `metrics.pathTracer.oidnMode` says `in-process` or `cli`) and writes the PNG as the other backends do: `denoise: true` means OIDN with the albedo and normal guides when `@codepawlhq/crucible-denoise-oidn` and its binary are installed, else (or when OIDN fails) the GPU a-trous filter of the native tracer with a note in `metrics.pathTracer.denoiserNote` (`denoiser: "atrous"`; it is biased, it smooths; `denoise: "wavelet"` asks for the CPU filter). The report carries `kernel` and `averageSamples`. The Cycles-matching kernel takes up to 4,000,000 unique triangles (copies of a shared mesh count once, and the scene may hold four times that with every copy counted); the job reads the scene from its page as one Blob over the DevTools stream (about half the time of returning it as base64, and no single message bounds it); the `cpu` backend and the older kernel keep 400,000, and the `gpu` backend takes what the page's WebGL2 context holds, up to 2,000,000 (see [path-tracer.md](https://github.com/codepawl/crucible/blob/main/docs/path-tracer.md)). A larger scene is refused with an error that names the limit. On the Cycles-matching kernel the job sends each material whole (FORMAT-v2 tables, instanced or not): blend opacity (`alphaMode: "blend"` with `opacity` below 1), sheen, `specular` and `specularColor`, anisotropy, iridescence, attenuation, and the clearcoat, transmission, sheen, anisotropy and coat normal maps all reach the kernel, and `metrics.pathTracer.ignored` lists only what it does not shade (the legacy kernel keeps the v1 tables and the old notes). A scene whose materials cannot be exported whole is traced from the v1 tables for that frame with the reason in `materialsReason`; the native tracer stays usable. It never fails for lack of the package: without it, without its built binary or without a Vulkan ray query adapter the job runs on `gpu` (`cpu` on a cpu runtime) and `metrics.pathTracer.backendNote` says why; `metrics.pathTracer.backend` always names what ran. The look up costs one import and is cached per process. Native traces volume fog and subsurface scattering with the same walk as the WebGPU megakernel, honours `maxSeconds`, and honours `noiseThreshold` on the GPU (after 16 samples, and then every 8, a converged pixel draws no more; `report.averageSamples` is the mean a pixel drew). The `gpu` fallback ignores `noiseThreshold`. The report in `metrics.pathTracer` names the `backend` that ran, the `gpu`, `gpuCompileSeconds` and `gpuKernelCompiles`. A `stills` or `video` job traces every frame with the same options: the kernel compiles once per job page and each frame reuses it, so a film shows `gpuKernelCompiles: 1`. A native `stills` or `video` job (the Cycles-matching kernel) also keeps one native session for the whole job: a frame that only moves the camera reuses the uploaded scene, the compiled kernel and the acceleration structures; changed materials, lights, instance transforms or triangles (the table may change length) are sent to the session, which rebuilds only the changed meshes' acceleration structures; a frame whose record counts, placed meshes, emissive meshes, textures or environment changed gets a new session, and a failed session update or render falls back to a new session or a one-shot trace for that frame. `metrics.pathTracer.nativeSession` says which one each frame took (`path` is `new-session`, `reused`, `updated` or `one-shot`, with `reason`, `changedTables`, `changedMeshes` (after a triangles update), `pipelineReused` and `accelerationReused`); `metrics.nativeSessionRoutes` lists the `path` of every frame. A job reuses the session only when the tables the page exports are equal to the previous frame's apart from the camera (`reused`), or differ in material values, lights, instance transforms or triangles (`updated`). Geometry that moves with the time, such as particle systems (sparks, swaying hair) or a moved node in a scene exported as flattened triangles, goes through `updated` and costs one BLAS build per changed mesh plus the TLAS. A changed emissive mesh, other record counts or another set of placed meshes gives that frame a new session, which costs what a one-shot trace costs and is byte-identical to it; `reason` names the first table that differed. A single-frame job and `JS67_NATIVE_KERNEL=legacy` trace one-shot and carry no `nativeSession`; `JS67_NATIVE_SESSIONS=off` in the server's environment traces every frame one-shot (default on). The session is closed when the job ends or fails, and every frame of a stills job equals the one-shot render byte for byte. A native video also blends its frames over time, so the noise the denoiser leaves does not shimmer from frame to frame: each pixel finds where its surface point was in the frame before (from the first-hit distance and the two cameras) and the filtered light is averaged with what was gathered there. A pixel whose surface was hidden, off screen, another surface or seen from a direction more than about 6 degrees away in the frame before starts again, so a cut to another view starts again too, and the whole image starts again at a new shot of a `timeline` and on any frame whose scene, light or render settings changed (its route is not `reused`), so a video with moving parts or lights, or a dip through black, gets no blending on those frames. Each frame of such a video traces with its own seed (`seed` plus the frame number), and `metrics.pathTracer.temporal` reports `historyShare` (the share of pixels that found their history, from the last frame) with `restarted` saying why an image started again. The blend assumes a still scene under a moving camera: light that depends on the view (a sharp reflection, a highlight, the view through glass) trails the camera by a few frames, and an orthographic camera is not blended. `JS67_NATIVE_TEMPORAL=off` in the server's environment turns the blending off, which makes every video frame equal its one-shot render again. A video of traced frames goes through the ffmpeg encoder (the browser H.264 encoder has no drawn frame to read), `maxSeconds` limits each frame, and the job deadline is `maxSeconds` times the frame count plus 60 seconds, up to the job ceiling. Limits: `samples` 1 to 1024, `bounces` 1 to 16, `seed` 0 to 2147483647, `maxSeconds` 1 to 600 (the job's deadline is `maxSeconds` plus 60 seconds; a 1920 by 1080 still of a 180,000 triangle room at 64 samples took 246 s, so give a large still `maxSeconds` 600). `passes` are refused with it, because the tracer has no object ID, depth or normal pass; part findings (framing, floating, intersecting, textures, z-fighting) still reach `metrics.diagnostics` from the first frame, with a `findings-unavailable` entry saying that exposure findings are not available on a traced job (see [mcp.md](mcp.md)). The tracer loads in the job page on demand, uses eight threads at below-normal priority, stops pixels that have converged (`report.averageSamples`), and writes `render.png`; `scene_render_result` metrics carry `pathTracer` with the samples, threads, seconds and what the scene asked for that was not drawn. The same recipe and seed give the same PNG on the cpu and gpu backends; the native Cycles-matching kernel is not always byte-identical between runs (on the demo room at 960 by 540 and 256 samples two jobs differed in a few bytes; a 480 by 270 job with OIDN did not). A job that passes `maxSeconds` fails and writes no image.
-A native frame that compiled its kernel says so in `metrics.pathTracer`: `compileSeconds` is the compile, `gpuTraceSeconds` the trace, and `pipelineCache` (`warm`, `cold`, `off`, `unsupported`) what Cook's on-disk pipeline cache did; a compile over one second adds `kernelCompileNote`. The first trace of each scene variant (a scene with no emitter is its own variant) compiles; later frames of the job reuse it, and so does the next process once the cache holds it. Details: [path-tracer.md](path-tracer.md).
+A native frame that compiled its kernel says so in `metrics.pathTracer`: `compileSeconds` is the compile, `gpuTraceSeconds` the trace; a compile over one second adds `kernelCompileNote`. The first trace of each scene variant (a scene with no emitter is its own variant) compiles; later frames of the job reuse it. Details: [path-tracer.md](path-tracer.md).
## Controller API
diff --git a/docs/path-tracer.md b/docs/path-tracer.md
index 7130e8e6..e99e738b 100644
--- a/docs/path-tracer.md
+++ b/docs/path-tracer.md
@@ -246,7 +246,7 @@ Files written: `<prefix>.png` (ACES tone map and gamma, the Crucible view transf
The report holds everything `traceFrameNative` reports (adapter, kernel, samples, `tracedSeconds`, denoiser, `triangles`, `instances`, `ignored`) plus:
- `loadSeconds` (Chrome loads the GLB and textures), `packSeconds` (the native tables), `setupSeconds` (both) and `samplingSeconds` (the trace). The tracer's own set-up time is `tracerSetupSeconds`.
-- Kernel compile, apart from trace time: Cook compiles one kernel per scene variant (a scene with no emitter is a different variant from a lit one), so the first trace of a variant in a process spends seconds in `compileSeconds` while `gpuTraceSeconds` stays the trace itself (`tracedSeconds` is the whole call, compile included). `pipelineCache` says what Cook's on-disk pipeline cache did when the device opened: `warm` (a file from an earlier process was loaded), `cold` (enabled, nothing stored yet), `off` (`COOK_PIPELINE_CACHE=off`) or `unsupported`. A compile over one second adds `kernelCompileNote`. The cache file lives in `%LOCALAPPDATA%\codepawl\cook\pipeline-cache` on Windows and `$XDG_CACHE_HOME/cook/pipeline-cache` (else `~/.cache/cook/pipeline-cache`) elsewhere; `COOK_PIPELINE_CACHE_DIR` moves it. A damaged, stale or over 64 MiB file is dropped and rebuilt.
+- Kernel compile, apart from trace time: Cook compiles one kernel per scene variant (a scene with no emitter is a different variant from a lit one), so the first trace of a variant in a process spends seconds in `compileSeconds` while `gpuTraceSeconds` stays the trace itself (`tracedSeconds` is the whole call, compile included). A compile over one second adds `kernelCompileNote`. On an RTX 3060 a new variant compiled in 5 to 26 s, against 0.02 s to trace it.
- `triangleCount` (unique triangles) and `instanceCount` (`null` when the scene is flattened).
- `lightCount`: the sun, point, spot and area lights packed for the kernel (emissive meshes are not counted), or `null` when the packer reports none.
- `peakGpuMemoryMiB`: the highest `memory.used` that `nvidia-smi` showed, sampled every 250 ms during the trace. It is the whole card, so other programs count; it is `null` with `peakGpuMemoryNote` when `nvidia-smi` is missing.
diff --git a/package-lock.json b/package-lock.json
index 8006590b..fefbfb2d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,7 +18,7 @@
"crucible-mcp": "bin/crucible-mcp.mjs"
},
"devDependencies": {
- "@codepawlhq/cook": "git+https://github.com/codepawl/cook.git#6563af34962a8a1f1bd1eaa54eb7ba52766aadd9",
+ "@codepawlhq/cook": "git+https://github.com/codepawl/cook.git#55f2448dbb5121d82a5b125c3564403b64798d03",
"@codepawlhq/crucible-denoise-oidn": "file:packages/denoise-oidn",
"@dimforge/rapier3d-compat": "0.21.0",
"@modelcontextprotocol/client": "2.4.0",
@@ -181,7 +181,7 @@
},
"node_modules/@codepawlhq/cook": {
"version": "0.2.0",
- "resolved": "git+https://github.com/codepawl/cook.git#6563af34962a8a1f1bd1eaa54eb7ba52766aadd9",
+ "resolved": "git+https://github.com/codepawl/cook.git#55f2448dbb5121d82a5b125c3564403b64798d03",
"integrity": "sha512-GstR1TXMXVrrvAn8DC3wzBpnGjzsulzRF8bEeUHGMN1D+6Du0ORGAIilx04FlQYSPlcnih8eyYECcuPHYjR+FA==",
"dev": true,
"license": "MIT AND Apache-2.0 AND BSD-3-Clause",
diff --git a/package.json b/package.json
index 0a1f236b..b9ee49bd 100644
--- a/package.json
+++ b/package.json
@@ -288,7 +288,7 @@
},
"devDependencies": {
"@codepawlhq/crucible-denoise-oidn": "file:packages/denoise-oidn",
- "@codepawlhq/cook": "git+https://github.com/codepawl/cook.git#6563af34962a8a1f1bd1eaa54eb7ba52766aadd9",
+ "@codepawlhq/cook": "git+https://github.com/codepawl/cook.git#55f2448dbb5121d82a5b125c3564403b64798d03",
"@dimforge/rapier3d-compat": "0.21.0",
"@modelcontextprotocol/client": "2.4.0",
"@modelcontextprotocol/server": "2.4.0",
diff --git a/scripts/agent-native-trace.mjs b/scripts/agent-native-trace.mjs
index 77c05a0d..abf056b0 100644
--- a/scripts/agent-native-trace.mjs
+++ b/scripts/agent-native-trace.mjs
@@ -349,18 +349,10 @@ const NOTEWORTHY_COMPILE_SECONDS = 1;
/**
* The sentence for a frame that spent seconds compiling its kernel, or undefined when it did not. Cook compiles one kernel per
* scene variant (a scene with no emitter is a different variant from a lit one), and the first trace of a variant pays for it.
- * `pipelineCache` is Cook's report of its on-disk cache: "warm", "cold", "off" or "unsupported" (absent on an older Cook).
*/
-export function describeKernelCompile({ compileSeconds, pipelineCache }) {
+export function describeKernelCompile({ compileSeconds }) {
if (!(compileSeconds >= NOTEWORTHY_COMPILE_SECONDS)) return undefined;
- const spent = `This frame spent ${compileSeconds.toFixed(1)} s compiling the kernel variant its scene needs, which is not trace time.`;
- const reuse = 'Later frames of this job reuse it.';
- if (pipelineCache === 'warm' || pipelineCache === 'cold') {
- return `${spent} ${reuse} Cook saved it in its pipeline cache, so the next process that renders the same scene variant skips the compile.`;
- }
- if (pipelineCache === 'off') return `${spent} ${reuse} Cook's pipeline cache is off (COOK_PIPELINE_CACHE=off), so every new process compiles it again.`;
- if (pipelineCache === 'unsupported') return `${spent} ${reuse} This adapter has no pipeline cache, so every new process compiles it again.`;
- return `${spent} ${reuse}`;
+ return `This frame spent ${compileSeconds.toFixed(1)} s compiling the kernel variant its scene needs, which is not trace time. Later frames of this job reuse it.`;
}
/**
@@ -421,11 +413,10 @@ async function traceOneFrameNative({ tracer, exported, width, height, samples, b
normalizeNormals(features.normal);
const averageSamples = traced.averageSamples ?? samples;
const estimatedNoise = estimateRelativeNoise({ color: features.color, variance: features.variance, averageSamples });
- const kernelCompileNote = describeKernelCompile({ compileSeconds: traced.compileSeconds, pipelineCache: traced.pipelineCache });
+ const kernelCompileNote = describeKernelCompile({ compileSeconds: traced.compileSeconds });
const report = { width, height, samples, bounces, seed, denoised: false, denoiser: 'none', threads: 1, backend: 'native',
gpu: traced.adapter, nativeBackend: traced.backend, nativeFeatures: traced.features, setupSeconds: traced.setupSeconds, compileSeconds: traced.compileSeconds,
uploadSeconds: traced.uploadSeconds, accelerationBuildSeconds: traced.accelerationBuildSeconds,
- ...(traced.pipelineCache === undefined ? {} : { pipelineCache: traced.pipelineCache }),
...(traced.tracedSeconds === undefined ? {} : { gpuTraceSeconds: traced.tracedSeconds }),
...(kernelCompileNote ? { kernelCompileNote } : {}),
kernel, averageSamples, noiseThreshold, ...(estimatedNoise === null ? {} : { estimatedNoise }), triangles: exported.triangles, inputBytes: tableBytes(tables), ...(exported.instances === undefined ? {} : { instances: exported.instances }),
diff --git a/tests/agent-native-trace.test.js b/tests/agent-native-trace.test.js
index 4f6b1d93..a98b089a 100644
--- a/tests/agent-native-trace.test.js
+++ b/tests/agent-native-trace.test.js
@@ -155,30 +155,24 @@ function tracerWithCompile(timings) {
return { traceNative: () => ({ ...traced, ...timings }) };
}
-test('a frame that spent seconds compiling says so apart from the trace time, and what the pipeline cache does about it', async () => {
+test('a frame that spent seconds compiling says so apart from the trace time', async () => {
const frame = { exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'none' };
- const cold = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 7.04, tracedSeconds: 0.017, pipelineCache: 'cold' }) });
- assert.equal(cold.report.compileSeconds, 7.04);
- assert.equal(cold.report.gpuTraceSeconds, 0.017);
- assert.equal(cold.report.pipelineCache, 'cold');
- assert.match(cold.report.kernelCompileNote, /spent 7\.0 s compiling the kernel variant/);
- assert.match(cold.report.kernelCompileNote, /next process that renders the same scene variant skips the compile/);
- const off = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 3, pipelineCache: 'off' }) });
- assert.match(off.report.kernelCompileNote, /COOK_PIPELINE_CACHE=off/);
- const unsupported = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 3, pipelineCache: 'unsupported' }) });
- assert.match(unsupported.report.kernelCompileNote, /no pipeline cache/);
+ const compiled = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 7.04, tracedSeconds: 0.017 }) });
+ assert.equal(compiled.report.compileSeconds, 7.04);
+ assert.equal(compiled.report.gpuTraceSeconds, 0.017);
+ assert.match(compiled.report.kernelCompileNote, /spent 7\.0 s compiling the kernel variant/);
+ assert.match(compiled.report.kernelCompileNote, /Later frames of this job reuse it/);
});
-test('a frame whose kernel was cached or compiled quickly carries no compile note, and an older Cook adds no cache fields', async () => {
+test('a frame whose kernel was held or compiled quickly carries no compile note, and an older Cook adds no trace field', async () => {
const frame = { exported: emptyExport, width: 4, height: 4, samples: 8, denoise: 'none' };
- const warm = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 0.05, tracedSeconds: 0.02, pipelineCache: 'warm' }) });
- assert.equal(warm.report.kernelCompileNote, undefined);
- assert.equal(warm.report.pipelineCache, 'warm');
+ const quick = await traceFrameNative({ ...frame, tracer: tracerWithCompile({ compileSeconds: 0.05, tracedSeconds: 0.02 }) });
+ assert.equal(quick.report.kernelCompileNote, undefined);
+ assert.equal(quick.report.gpuTraceSeconds, 0.02);
const older = await traceFrameNative({ ...frame, tracer: tracerRecording([]) });
- assert.equal('pipelineCache' in older.report, false);
assert.equal('gpuTraceSeconds' in older.report, false);
- assert.equal(describeKernelCompile({ compileSeconds: 2 }).includes('pipeline cache'), false);
- assert.equal(describeKernelCompile({ compileSeconds: undefined, pipelineCache: 'cold' }), undefined);
+ assert.equal('kernelCompileNote' in older.report, false);
+ assert.equal(describeKernelCompile({ compileSeconds: undefined }), undefined);
});
const emptyExport = {