mirror of
https://github.com/siemens-mobile-hacks/pmb887x-emu-web.git
synced 2026-11-25 22:27:22 +00:00
tools: the wasm probes time on an empty page of the site's origin
dispsize, callref, modshape, modfloor (without BUSY), modgrow, wasmclone and wasmcache opened index.html, whose engine prefetch fetches and compiles site/dist-jit/qemu-system-arm.wasm (and siemens-recalc.wasm) in the background while they time compiles and calls. They now go to /probe-blank.html, which Playwright answers itself (tools/lib/page.mjs gotoBlank): same origin, COOP/COEP, Cache API and IndexedDB, and no request reaches the server. Checked on a scratch server: index.html requested both wasm files within 6 s of the load; the blank page made one (routed) request and none reached the server, with crossOriginIsolated true. modgrow ran at --total 500. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xda8d7rfJjkFSmKVQtcBGh
This commit is contained in:
parent
078abe224f
commit
b0b7cbfac2
8 changed files with 33 additions and 9 deletions
|
|
@ -22,6 +22,7 @@
|
|||
// one per function) shuffled with xorshift32, and the results of that time
|
||||
// need re-measurement.
|
||||
import { chromium } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const opt = (n, d) => { const i = argv.indexOf("--" + n); return i >= 0 && argv[i + 1] ? argv[i + 1] : d; };
|
||||
|
|
@ -114,7 +115,7 @@ return out;
|
|||
const b = await chromium.launch({ headless: true });
|
||||
const p = await b.newPage();
|
||||
p.on("pageerror", (e) => console.log("[pageerror]", String(e).slice(0, 300)));
|
||||
await p.goto(`http://127.0.0.1:${PORT}/`, { waitUntil: "domcontentloaded" });
|
||||
await gotoBlank(p, `http://127.0.0.1:${PORT}`);
|
||||
const r = await p.evaluate(`(() => { ${PROBE.replace("__FUNCS__", String(FUNCS))
|
||||
.replace("__ITERS__", String(ITERS)).replace("__REPS__", String(REPS))} })()`);
|
||||
console.log(`funcs=${FUNCS}, ${ITERS} dispatches, random walk`);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
// its low bits: over 4096 functions it reached about 84, and the array's
|
||||
// 8192 entries capped every larger F. Its results need re-measurement.
|
||||
import { chromium } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const opt = (n, d) => { const i = argv.indexOf("--" + n); return i >= 0 && argv[i + 1] ? argv[i + 1] : d; };
|
||||
|
|
@ -120,7 +121,7 @@ return out;
|
|||
const b = await chromium.launch({ headless: true });
|
||||
const p = await b.newPage();
|
||||
p.on("pageerror", (e) => console.log("[pageerror]", String(e).slice(0, 300)));
|
||||
await p.goto(`http://127.0.0.1:${PORT}/`, { waitUntil: "domcontentloaded" });
|
||||
await gotoBlank(p, `http://127.0.0.1:${PORT}`);
|
||||
const rows = await p.evaluate(`(() => { ${PROBE.replace("__SIZES__", JSON.stringify(SIZES))
|
||||
.replace("__ITERS__", String(ITERS)).replace("__REPS__", String(REPS))} })()`);
|
||||
console.log(`${ITERS} dispatches per point, ns each`);
|
||||
|
|
|
|||
|
|
@ -98,3 +98,18 @@ export const QEMULOG_SINCE = `((log, seen) => {
|
|||
const from = Math.max(seen, first);
|
||||
return { lines: log.slice(from - first), total, lost: from - seen };
|
||||
})`;
|
||||
|
||||
// An empty page at origin (e.g. "http://127.0.0.1:19100"), answered by the
|
||||
// browser itself: the wasm probes time compiles and calls with that origin's
|
||||
// storage and headers, and index.html would fetch and compile the engine in
|
||||
// the background meanwhile (its prefetch). No request reaches the server.
|
||||
export async function gotoBlank(page, origin, ms = 60000) {
|
||||
const url = new URL("/probe-blank.html", origin).href;
|
||||
await page.route(url, (route) => route.fulfill({
|
||||
status: 200,
|
||||
contentType: "text/html",
|
||||
headers: { "cross-origin-opener-policy": "same-origin", "cross-origin-embedder-policy": "require-corp" },
|
||||
body: "<!doctype html><title>probe</title>",
|
||||
}));
|
||||
await page.goto(url, { waitUntil: "domcontentloaded", timeout: ms });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
//
|
||||
// PORT=8080 [BUSY=1 TESTFLASH=...] node tools/modfloor.mjs
|
||||
import { chromium } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
// BUSY=1 boots a board first, so the synthetic runs against the same
|
||||
// machine load the vCPU worker's own compiles see.
|
||||
|
|
@ -31,7 +32,9 @@ const port = process.env.PORT || "8080";
|
|||
const busy = process.env.BUSY === "1";
|
||||
const b = await chromium.launch({ headless: true });
|
||||
const p = await b.newPage();
|
||||
await p.goto(`http://127.0.0.1:${port}/?dist=dist-jit`, { waitUntil: "domcontentloaded" });
|
||||
// BUSY boots on the real page; otherwise nothing else compiles meanwhile
|
||||
if (busy) await p.goto(`http://127.0.0.1:${port}/?dist=dist-jit`, { waitUntil: "domcontentloaded" });
|
||||
else await gotoBlank(p, `http://127.0.0.1:${port}`);
|
||||
if (busy) {
|
||||
await p.click("#ff-mode-own");
|
||||
await p.setInputFiles("#fullflash", (await import("./testflash.mjs")).fullflash);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
// drop them and re-measure, which separates "the live set is the cost"
|
||||
// from "the isolate got dirty and stays dirty".
|
||||
import { chromium } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const opt = (n, d) => { const i = argv.indexOf("--" + n); return i >= 0 && argv[i + 1] ? argv[i + 1] : d; };
|
||||
|
|
@ -105,7 +106,7 @@ return { rows, bytes, dropUs, kept: after.length };
|
|||
const b = await chromium.launch({ headless: true, args: process.env.JS_FLAGS ? [`--js-flags=${process.env.JS_FLAGS}`] : [] });
|
||||
const p = await b.newPage();
|
||||
p.on("pageerror", (e) => console.log(`pageerror: ${String(e).slice(0, 300)}`));
|
||||
await p.goto(`http://127.0.0.1:${PORT}/`, { waitUntil: "domcontentloaded", timeout: 120000 });
|
||||
await gotoBlank(p, `http://127.0.0.1:${PORT}`, 120000);
|
||||
let r;
|
||||
try {
|
||||
r = await p.evaluate(`(async () => { ${PROBE.replaceAll("__TOTAL__", String(TOTAL))
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
// G:distinct+cold the 30 variants G:distinct had just compiled: those
|
||||
// results measured the cache.
|
||||
import { chromium } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const port = process.env.PORT || "8080";
|
||||
|
||||
|
|
@ -158,7 +159,7 @@ const probe = () => {
|
|||
|
||||
const b = await chromium.launch({ headless: true });
|
||||
const p = await b.newPage();
|
||||
await p.goto(`http://127.0.0.1:${port}/`, { waitUntil: "domcontentloaded" });
|
||||
await gotoBlank(p, `http://127.0.0.1:${port}`);
|
||||
const r = await p.evaluate(probe);
|
||||
await b.close();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { chromium, firefox } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const opt = (n, d) => { const i = argv.indexOf("--" + n); return i >= 0 && argv[i + 1] ? argv[i + 1] : d; };
|
||||
|
|
@ -69,11 +70,11 @@ async function run(count, phase, tag) {
|
|||
`;
|
||||
const src = (phase, tag, count) => `(async () => {\n${BODY}\nreturn run(${count}, ${JSON.stringify(phase)}, ${JSON.stringify(tag)});\n})()`;
|
||||
|
||||
// a browser on the profile in dir, and a page of the site in it
|
||||
// a browser on the profile in dir, and an empty page of the site's origin in it
|
||||
async function open(B, dir) {
|
||||
const ctx = await B.launchPersistentContext(dir, { headless: true });
|
||||
const p = ctx.pages()[0] || await ctx.newPage();
|
||||
await p.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
|
||||
await gotoBlank(p, url);
|
||||
return { ctx, p };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { chromium, firefox } from "playwright-core";
|
||||
import { gotoBlank } from "./lib/page.mjs";
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
const opt = (n, d) => { const i = argv.indexOf("--" + n); return i >= 0 && argv[i + 1] ? argv[i + 1] : d; };
|
||||
|
|
@ -178,12 +179,12 @@ const probeSrc = (phase, db) => `(async () => {\nconst OPSARG = ${OPS};\n${PROBE
|
|||
|
||||
const fmt = (us) => us == null ? "-" : us >= 1000 ? (us / 1000).toFixed(1) + " ms" : us.toFixed(1) + " us";
|
||||
|
||||
// a browser on the profile in dir, and a page of the site in it
|
||||
// a browser on the profile in dir, and an empty page of the site's origin in it
|
||||
async function open(B, name, dir) {
|
||||
const ctx = await B.launchPersistentContext(dir, { headless: true });
|
||||
const p = ctx.pages()[0] || await ctx.newPage();
|
||||
p.on("crash", () => console.log(`WASMCLONE ${name}: !! page crashed`));
|
||||
await p.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
|
||||
await gotoBlank(p, url);
|
||||
return { ctx, p };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue