Skip to content

Open source CapCut alternative.

TypeScript

test(site): the preview perf gate reads the low-end profile

David Lec4dc512c893d
diff --git a/docs/guides/cut/README.md b/docs/guides/cut/README.md
index 0fb386e5..88550633 100644
--- a/docs/guides/cut/README.md
+++ b/docs/guides/cut/README.md
@@ -52,6 +52,8 @@ The playhead lives apart from the document. It moves sixty times a second and th
Whether any of this is true of a given build is measured rather than assumed: `npm run eval:cut-perf` drives a real editor in a real browser against fixture montages and reports how long the picture takes to answer a moved playhead, whether any frame crossing a cut was the wrong one, and whether a fast-cut montage replayed for minutes still holds the picture to the clock the way its first pass did. Its committed report is the baseline a change is diffed against.
+The machine it measures on is part of the measurement. A developer desktop has decode slots to spare and never falls behind, so the preview's caps never bind there and a change that would ruin a laptop reads as a clean sheet. `--machine` puts the page on a smaller one: it takes away hardware decode slots, so decoders past the limit deliver their frames late the way software decoding does, and it slows the main thread to a fraction of this one. `npm run eval:cut-perf-lowend` is the profile the reports come from. What the gates ask there is what a viewer would ask — did the frames arrive, did the picture hitch a quarter second behind the sound, and was the last pass as good as the first — and each machine has its own budget for those, because a number that is honest on a desktop is fantasy on a fifteen-watt laptop.
+
## Color grading
A clip's color is one field on the clip: an optional preset underneath and manual adjustments on top — sliders, tone curves, color wheels, per-hue bands. Every part is absent when neutral, so an untouched clip carries nothing, and the preset's intensity scales its parameters toward neutral so half-strength means half the move, never a crossfade through gray.
diff --git a/evals/cut-perf.latest-report.json b/evals/cut-perf.latest-report.json
index 25e38bff..ce920b02 100644
--- a/evals/cut-perf.latest-report.json
+++ b/evals/cut-perf.latest-report.json
@@ -1,5 +1,15 @@
{
"schema": "cut-perf-eval/v1",
+ "machine": {
+ "name": "desktop",
+ "cpu": 1,
+ "slots": 0,
+ "softwareMs": 0,
+ "lagP95S": 0.05,
+ "stallShare": 0.002,
+ "lateShare": 0.02,
+ "decayFloor": 0.02
+ },
"gate": {
"scrubP50Ms": 10,
"scrubP95Ms": 16.7,
@@ -11,7 +21,10 @@
"lagP95S": 0.05,
"lagMaxS": 0.25,
"decayRatio": 1.5,
- "warmMb": 400
+ "warmMb": 400,
+ "stallShare": 0.002,
+ "lateShare": 0.02,
+ "decayFloor": 0.02
},
"fixture": {
"clips": 6,
@@ -24,10 +37,10 @@
"pass": true,
"notes": [],
"scrub": {
- "p50": 7.5,
- "p95": 15.8,
- "mean": 8.59,
- "max": 21.5,
+ "p50": 7.4,
+ "p95": 15.6,
+ "mean": 8.45,
+ "max": 24.1,
"n": 41
},
"longTasks": {
@@ -37,7 +50,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 60
+ "liveSamples": 81,
+ "machine": "desktop"
},
{
"name": "drag-across-a-cut",
@@ -45,10 +59,10 @@
"pass": true,
"notes": [],
"scrub": {
- "p50": 7.5,
- "p95": 16.1,
- "mean": 8.8,
- "max": 19.6,
+ "p50": 7.4,
+ "p95": 15.7,
+ "mean": 8.2,
+ "max": 16.4,
"n": 41
},
"longTasks": {
@@ -58,7 +72,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 52
+ "liveSamples": 77,
+ "machine": "desktop"
},
{
"name": "drag-across-a-transition",
@@ -66,10 +81,10 @@
"pass": true,
"notes": [],
"scrub": {
- "p50": 7.5,
- "p95": 15.8,
- "mean": 8.59,
- "max": 22.9,
+ "p50": 7.4,
+ "p95": 15.7,
+ "mean": 8.34,
+ "max": 17.9,
"n": 41
},
"longTasks": {
@@ -79,7 +94,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 63
+ "liveSamples": 64,
+ "machine": "desktop"
},
{
"name": "jump-across-the-cut",
@@ -87,10 +103,10 @@
"pass": true,
"notes": [],
"scrub": {
- "p50": 15.9,
- "p95": 24,
- "mean": 15.6,
- "max": 25.6,
+ "p50": 15.5,
+ "p95": 18.2,
+ "mean": 14.96,
+ "max": 23.7,
"n": 41
},
"longTasks": {
@@ -100,7 +116,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 88
+ "liveSamples": 71,
+ "machine": "desktop"
},
{
"name": "play-hard-cuts",
@@ -108,7 +125,7 @@
"pass": true,
"notes": [],
"drops": 0,
- "presented": 2076,
+ "presented": 2075,
"boundaryDrops": 0,
"longTasks": {
"p50": 0,
@@ -117,7 +134,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 60
+ "liveSamples": 60,
+ "machine": "desktop"
},
{
"name": "play-with-transitions",
@@ -125,7 +143,7 @@
"pass": true,
"notes": [],
"drops": 0,
- "presented": 2076,
+ "presented": 2074,
"boundaryDrops": 0,
"longTasks": {
"p50": 0,
@@ -134,7 +152,8 @@
"max": 0,
"n": 0
},
- "liveSamples": 60
+ "liveSamples": 60,
+ "machine": "desktop"
},
{
"name": "play-fast-cuts",
@@ -142,14 +161,15 @@
"pass": true,
"notes": [],
"drops": 0,
- "presented": 1619,
+ "presented": 1617,
"lag": {
"p50": 0.02,
"p95": 0.03,
"mean": 0.02,
"max": 0.03,
- "n": 1619
+ "n": 1617
},
+ "stallShare": 0,
"decay": {
"first": 0,
"last": 0
@@ -164,7 +184,8 @@
"liveSamples": 120,
"liveSources": 12,
"keptSources": 20,
- "warmMb": 354
+ "warmMb": 354,
+ "machine": "desktop"
},
{
"name": "play-fast-cuts-long",
@@ -180,6 +201,7 @@
"max": 0.03,
"n": 6481
},
+ "stallShare": 0,
"decay": {
"first": 0,
"last": 0
@@ -194,7 +216,8 @@
"liveSamples": 120,
"liveSources": 12,
"keptSources": 20,
- "warmMb": 354
+ "warmMb": 354,
+ "machine": "desktop"
},
{
"name": "idle-costs-nothing",
diff --git a/site/package.json b/site/package.json
index 2dd6abd7..3a9a7477 100644
--- a/site/package.json
+++ b/site/package.json
@@ -28,6 +28,7 @@
"test:genvideo": "bun run scripts/genvideo-selftest.ts",
"eval:genvideo": "bun run scripts/genvideo-eval.ts",
"eval:cut-perf": "bun run scripts/eval-cut-perf.ts",
+ "eval:cut-perf-lowend": "bun run scripts/eval-cut-perf.ts --bucket playback --runs 3 --machine ryzen-5500u",
"eval:cut-sync": "bun run scripts/eval-cut-sync.ts",
"eval:cut-export": "bun run scripts/eval-cut-export.ts"
},
diff --git a/site/scripts/eval-cut-perf.ts b/site/scripts/eval-cut-perf.ts
index 9356c707..c8197b09 100644
--- a/site/scripts/eval-cut-perf.ts
+++ b/site/scripts/eval-cut-perf.ts
@@ -98,6 +98,10 @@ interface Machine {
* often it happens says whether the picture hitches; the worst single frame
* says only that a seek happened. */
stallShare: number;
+ /** Late-frame share below which a rise across the play is noise. A machine
+ * already dropping a few frames swings by a few frames run to run, and a
+ * ratio between two small numbers reads that as decay every other run. */
+ decayFloor: number;
/** Share of played frames that may show a picture which does not belong at
* that instant. This is the plainest reading of "does the video play": a
* frame the decoder failed to deliver on time is a frame the viewer sees
@@ -108,15 +112,15 @@ interface Machine {
const MACHINES: Machine[] = [
// The machine this is being written on: nothing binds, and the numbers are
// held to the tightest budget in the file.
- { name: "desktop", cpu: 1, slots: 0, softwareMs: 0, lagP95S: 0.05, stallShare: 0.002, lateShare: 0.02 },
+ { name: "desktop", cpu: 1, slots: 0, softwareMs: 0, lagP95S: 0.05, stallShare: 0.002, lateShare: 0.02, decayFloor: 0.02 },
// A mainstream laptop with an integrated GPU.
- { name: "laptop", cpu: 4, slots: 6, softwareMs: 6, lagP95S: 0.06, stallShare: 0.02, lateShare: 0.06 },
+ { name: "laptop", cpu: 4, slots: 6, softwareMs: 6, lagP95S: 0.06, stallShare: 0.04, lateShare: 0.1, decayFloor: 0.1 },
// The one people report from: a 15W six-core with Vega graphics, running a
// browser that is also drawing the editor.
- { name: "ryzen-5500u", cpu: 10, slots: 4, softwareMs: 8, lagP95S: 0.06, stallShare: 0.03, lateShare: 0.06 },
+ { name: "ryzen-5500u", cpu: 10, slots: 4, softwareMs: 8, lagP95S: 0.06, stallShare: 0.03, lateShare: 0.05, decayFloor: 0.08 },
// Worse than anything anyone has reported, which is the point: what holds
// here holds on the machines that have not written in yet.
- { name: "potato", cpu: 20, slots: 2, softwareMs: 12, lagP95S: 0.3, stallShare: 0.12, lateShare: 0.32 },
+ { name: "potato", cpu: 20, slots: 2, softwareMs: 12, lagP95S: 0.1, stallShare: 0.06, lateShare: 0.2, decayFloor: 0.15 },
];
const MACHINE_NAME = arg("--machine") ?? "desktop";
@@ -163,9 +167,9 @@ const BASE_GATE = {
// Sound is scheduled against the clock the picture is drawn from, so how far
// the picture sits behind the source moment it was asked for is how far it
// sits behind the sound. A frame either side of the ask is the picture
- // keeping up; a quarter second is a viewer noticing.
+ // keeping up; a quarter second is a viewer noticing. Each machine profile
+ // sets its own, since what is honest on a desktop is fantasy on a laptop.
lagP95S: 0.05,
- lagMaxS: 0.25,
// A long play must end the way it began: a session that decays is the bug
// this case exists to catch.
decayRatio: 1.5,
@@ -182,6 +186,13 @@ const GATE = {
lagP95S: MACHINE.lagP95S,
stallShare: MACHINE.stallShare,
lateShare: MACHINE.lateShare,
+ decayFloor: MACHINE.decayFloor,
+ // A long task is a budget on work, and the throttle divides how much work
+ // fits in a millisecond. Thirteen milliseconds of compositing is thirteen
+ // milliseconds of compositing whether the CPU runs it in sixteen or in a
+ // hundred and sixty, so the budget scales with the machine and keeps meaning
+ // the same thing.
+ longTaskMs: BASE_GATE.longTaskMs * MACHINE.cpu,
};
/** How far behind the sound the picture has to be for that frame to read as a
@@ -359,9 +370,18 @@ const SHOT_INS = Array.from({ length: SHOTS }, (_, i) => {
});
/** Seed the montage: one asset, many short clips, each its own mapping. */
-const seedMontage = async (page: Page): Promise<Fixture> =>
+/**
+ * The montage, optionally wearing what a real project wears.
+ *
+ * The bare fixture is footage and cuts, which measures the decoders and very
+ * little else. A cut people actually make carries a look and a grade, and both
+ * are per-frame work on the compositor's side of the fence — the side a weak
+ * CPU runs out of first. Measuring only the bare one leaves the cost that
+ * shows up in the reports unmeasured.
+ */
+const seedMontage = (dressed = false) => async (page: Page): Promise<Fixture> =>
page.evaluate(
- async ({ ins, shot, srcDuration }) => {
+ async ({ ins, shot, srcDuration, dressed }) => {
const dev = (window as unknown as {
__cutDev: { useEditor: { getState(): Record<string, unknown>; setState(p: unknown): void } };
}).__cutDev;
@@ -385,6 +405,13 @@ const seedMontage = async (page: Page): Promise<Fixture> =>
start: +(i * shot).toFixed(3),
in: inPoint,
out: +(inPoint + shot).toFixed(3),
+ ...(dressed
+ ? {
+ look: "vhs",
+ lookAmount: 0.8,
+ grade: { contrast: 12, saturation: 10, temperature: 8, shadows: -6 },
+ }
+ : {}),
})),
audioClips: [],
overlays: [],
@@ -397,7 +424,7 @@ const seedMontage = async (page: Page): Promise<Fixture> =>
duration: +(ins.length * shot).toFixed(3),
};
},
- { ins: SHOT_INS, shot: SHOT_S, srcDuration: MONTAGE_SRC_S }
+ { ins: SHOT_INS, shot: SHOT_S, srcDuration: MONTAGE_SRC_S, dressed }
);
/** Where the scene-cut fixture changes scene: every three seconds. */
@@ -798,11 +825,11 @@ const playbackCase = (name: string, transitions: boolean): EvalCase => ({
* pass answers "does a fast cut play"; several answer "does it still play after
* a while", which is the complaint this case was written for.
*/
-const montageCase = (name: string, passes: number): EvalCase => ({
+const montageCase = (name: string, passes: number, dressed = false): EvalCase => ({
name,
bucket: "playback",
transitions: false,
- seed: seedMontage,
+ seed: seedMontage(dressed),
run: async (page, fx) => {
await rewind(page);
// One pass before the trace, so what follows measures playing rather than
@@ -934,7 +961,7 @@ const montageCase = (name: string, passes: number): EvalCase => ({
if (stallShare > GATE.stallShare) {
notes.push(`picture hitched a quarter second behind on ${(stallShare * 100).toFixed(1)}% of frames`);
}
- if (passes > 1 && decay.last > Math.max(0.02, decay.first * GATE.decayRatio)) {
+ if (passes > 1 && decay.last > Math.max(GATE.decayFloor, decay.first * GATE.decayRatio)) {
notes.push(`late frames rose ${decay.first} → ${decay.last} over the play`);
}
const warmMb = Math.max(0, ...trace.warmMb);
@@ -1307,6 +1334,9 @@ const CASES: EvalCase[] = [
playbackCase("play-with-transitions", true),
montageCase("play-fast-cuts", 1),
montageCase("play-fast-cuts-long", 4),
+ // The same montage graded and looked, which is what the cost of a real
+ // project's frame looks like on a machine that has none to spare.
+ montageCase("play-fast-cuts-graded", 2, true),
idleCase,
filmstripCase,
filmstripCutsCase,