From b625e7df2203b7804651a4f097d53cfcb6bda722 Mon Sep 17 00:00:00 2001 From: Project516 <138796702+Project516@users.noreply.github.com> Date: Wed, 7 Oct 2026 12:39:52 -0500 Subject: [PATCH] Record the JSPI core's size in core-sizes.json and compute the docs' size comparison from it. --- apps/website/docs/getting-started/usage.md | 8 ++++---- apps/website/src/data/core-sizes.json | 4 ++++ scripts/update-core-sizes.mjs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/website/docs/getting-started/usage.md b/apps/website/docs/getting-started/usage.md index 90d186a4173..d0aa0c24091 100644 --- a/apps/website/docs/getting-started/usage.md +++ b/apps/website/docs/getting-started/usage.md @@ -574,9 +574,9 @@ Asyncify, which rewrites the wasm code. The JSPI core does the same job with [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration), a feature of the browser and Node.js. It runs the same FFmpeg and the same `src/pthread-fiber` scheduler, so it needs no `SharedArrayBuffer`. Its wasm -file is about 19% smaller than the default core's (32.4 MB against 40.1 MB, -before compression), and the CI benchmark cases ran faster and used less -memory. +file is about {Math.round((1 - coreSizes["core-jspi"]["ffmpeg-core.wasm"] / coreSizes.core["ffmpeg-core.wasm"]) * 100)}% smaller than the default core's +({(coreSizes["core-jspi"]["ffmpeg-core.wasm"] / 1e6).toFixed(1)} MB against {(coreSizes.core["ffmpeg-core.wasm"] / 1e6).toFixed(1)} MB, before compression), and the CI +benchmark cases ran faster and used less memory. It needs a runtime with JSPI: Chrome 137 or later, Firefox 153 or later, Safari 27 or later, or Node.js 24 or later (tested on 24.21.0, and an older @@ -626,7 +626,7 @@ return a Promise instead of a number, so `await` them. - It has only been tested on short clips in CI, the wrapper test suites and FFmpeg's FATE tests. It has had no long-running or large-file testing, and no memory-leak testing over many commands. -- It is not on the Playground, and its size is not in `core-sizes.json`. +- It is not on the Playground. ## Node.js diff --git a/apps/website/src/data/core-sizes.json b/apps/website/src/data/core-sizes.json index 4d0cdc253ac..27c822da108 100644 --- a/apps/website/src/data/core-sizes.json +++ b/apps/website/src/data/core-sizes.json @@ -7,5 +7,9 @@ "core-mt": { "ffmpeg-core.js": 113289, "ffmpeg-core.wasm": 32778819 + }, + "core-jspi": { + "ffmpeg-core.js": 97901, + "ffmpeg-core.wasm": 32412275 } } diff --git a/scripts/update-core-sizes.mjs b/scripts/update-core-sizes.mjs index 0b9733c8f15..4a908a0cd48 100644 --- a/scripts/update-core-sizes.mjs +++ b/scripts/update-core-sizes.mjs @@ -4,7 +4,7 @@ // // Usage: node scripts/update-core-sizes.mjs [--run ] // Default reads the published packages from the jsDelivr data API. --run -// reads the ffmpeg-core and ffmpeg-core-mt artifacts of a CI run with gh +// reads the ffmpeg-core, -core-mt and -core-jspi artifacts of a CI run with gh // instead, for a release PR whose version is not published yet. The cores // are built from the same inputs, so the sizes hold for the tag. import { execFileSync } from "node:child_process"; @@ -48,7 +48,7 @@ async function sizesFromJsdelivr(pkg) { const sizes = { version }; const scratch = mkdtempSync(join(tmpdir(), "core-sizes-")); try { - for (const pkg of ["core", "core-mt"]) { + for (const pkg of ["core", "core-mt", "core-jspi"]) { sizes[pkg] = flag ? sizesFromRun(pkg, scratch) : await sizesFromJsdelivr(pkg); } } finally {