Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test(perf): measure the layout switch, not the test driver
joshistoast9400527c1fe1
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex e35ea824ff..f3056ddaaa 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -25,11 +25,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 109.79999999888241,+ "domContentLoadedMedianMs": 111.69999999925494,"id": "launchpad","layoutSwitchMedianMs": 0,- "loadMedianMs": 109.79999999888241,- "longestTaskMaxMs": 70,+ "loadMedianMs": 111.80000000074506,+ "longestTaskMaxMs": 69,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -56,7 +56,7 @@"scriptRequestCount": 15,"totalRawBytes": 1584282},- "routeReadyMedianMs": 225.09999999962747,+ "routeReadyMedianMs": 227.19999999925494,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -83,11 +83,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 106.40000000037253,+ "domContentLoadedMedianMs": 107.20000000111759,"id": "launchpad","layoutSwitchMedianMs": 0,- "loadMedianMs": 106.40000000037253,- "longestTaskMaxMs": 67,+ "loadMedianMs": 107.20000000111759,+ "longestTaskMaxMs": 68,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -114,7 +114,7 @@"scriptRequestCount": 15,"totalRawBytes": 1584282},- "routeReadyMedianMs": 276.7999999988824,+ "routeReadyMedianMs": 278.8999999985099,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -141,13 +141,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 109.19999999925494,+ "domContentLoadedMedianMs": 111.5,"id": "editor-minimal","layoutSwitchMedianMs": 0,- "loadMedianMs": 109.19999999925494,- "longestTaskMaxMs": 114,+ "loadMedianMs": 111.5,+ "longestTaskMaxMs": 111,"owner": "workbench",- "projectSwitchMedianMs": 61.89809799999966,+ "projectSwitchMedianMs": 64.53097400000115,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -172,7 +172,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 609,+ "routeReadyMedianMs": 614.6999999992549,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -199,13 +199,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 111.79999999888241,+ "domContentLoadedMedianMs": 112.90000000037253,"id": "editor-minimal","layoutSwitchMedianMs": 0,- "loadMedianMs": 111.90000000037253,- "longestTaskMaxMs": 123,+ "loadMedianMs": 113,+ "longestTaskMaxMs": 128,"owner": "workbench",- "projectSwitchMedianMs": 78.9058159999986,+ "projectSwitchMedianMs": 85.25626399999965,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -230,7 +230,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 657.5999999996275,+ "routeReadyMedianMs": 663.1999999992549,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -257,11 +257,11 @@"scriptRequestCount": 7,"totalRawBytes": 293339},- "domContentLoadedMedianMs": 110.70000000111759,+ "domContentLoadedMedianMs": 114.40000000037253,"id": "editor-canvas",- "layoutSwitchMedianMs": 325.7999999988824,- "loadMedianMs": 110.70000000111759,- "longestTaskMaxMs": 117,+ "layoutSwitchMedianMs": 81.5,+ "loadMedianMs": 114.40000000037253,+ "longestTaskMaxMs": 115,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -288,7 +288,7 @@"scriptRequestCount": 93,"totalRawBytes": 3518114},- "routeReadyMedianMs": 752.0999999996275,+ "routeReadyMedianMs": 767.3000000007451,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -315,11 +315,11 @@"scriptRequestCount": 7,"totalRawBytes": 293339},- "domContentLoadedMedianMs": 111.09999999962747,+ "domContentLoadedMedianMs": 114.30000000074506,"id": "editor-canvas",- "layoutSwitchMedianMs": 668.3999999985099,- "loadMedianMs": 111.09999999962747,- "longestTaskMaxMs": 369,+ "layoutSwitchMedianMs": 325.7000000011176,+ "loadMedianMs": 114.30000000074506,+ "longestTaskMaxMs": 381,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -346,7 +346,7 @@"scriptRequestCount": 93,"totalRawBytes": 3518114},- "routeReadyMedianMs": 1122.6000000014901,+ "routeReadyMedianMs": 1164.4000000003725,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -373,11 +373,11 @@"scriptRequestCount": 3,"totalRawBytes": 14378},- "domContentLoadedMedianMs": 108.40000000037253,+ "domContentLoadedMedianMs": 110.39999999850988,"id": "editor-workflow",- "layoutSwitchMedianMs": 411.69999999925494,- "loadMedianMs": 108.40000000037253,- "longestTaskMaxMs": 110,+ "layoutSwitchMedianMs": 71.69999999925494,+ "loadMedianMs": 110.5,+ "longestTaskMaxMs": 112,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -404,7 +404,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 820.2000000011176,+ "routeReadyMedianMs": 750.6999999992549,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -431,11 +431,11 @@"scriptRequestCount": 3,"totalRawBytes": 14378},- "domContentLoadedMedianMs": 110.5,+ "domContentLoadedMedianMs": 112.90000000037253,"id": "editor-workflow",- "layoutSwitchMedianMs": 484.90000000037253,- "loadMedianMs": 110.5,- "longestTaskMaxMs": 386,+ "layoutSwitchMedianMs": 136.59999999962747,+ "loadMedianMs": 112.90000000037253,+ "longestTaskMaxMs": 464,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -462,7 +462,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 945.3000000007451,+ "routeReadyMedianMs": 977.9000000003725,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -489,11 +489,11 @@"scriptRequestCount": 3,"totalRawBytes": 14378},- "domContentLoadedMedianMs": 109.69999999925494,+ "domContentLoadedMedianMs": 111.19999999925494,"id": "editor-gallery",- "layoutSwitchMedianMs": 268.8999999985099,- "loadMedianMs": 109.69999999925494,- "longestTaskMaxMs": 109,+ "layoutSwitchMedianMs": 26.5,+ "loadMedianMs": 111.19999999925494,+ "longestTaskMaxMs": 112,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -520,7 +520,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 681,+ "routeReadyMedianMs": 708.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -547,11 +547,11 @@"scriptRequestCount": 3,"totalRawBytes": 14378},- "domContentLoadedMedianMs": 110.80000000074506,+ "domContentLoadedMedianMs": 110.19999999925494,"id": "editor-gallery",- "layoutSwitchMedianMs": 398.59999999962747,- "loadMedianMs": 110.80000000074506,- "longestTaskMaxMs": 124,+ "layoutSwitchMedianMs": 39.40000000037253,+ "loadMedianMs": 110.19999999925494,+ "longestTaskMaxMs": 119,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -578,7 +578,7 @@"scriptRequestCount": 89,"totalRawBytes": 3239153},- "routeReadyMedianMs": 863,+ "routeReadyMedianMs": 857,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}diff --git a/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs b/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjsindex 64e191cf44..0a385d8665 100644--- a/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs+++ b/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs@@ -320,28 +320,56 @@ const runSample = async (browser, fixture, sample) => {const beforePaths = new Set(beforeActivation.map((resource) => resource.path));const interactionMark = `invokeai:interaction:${fixture.id}:${fixture.stateProfile}:layout-switch`;+ // Open the menu BEFORE starting the clock, and let the page stamp the+ // interaction mark itself when the selection actually lands.+ //+ // Marking from the driver ahead of `presetTrigger.click()` folded two costs+ // that are not the app's into the measurement: opening the menu, and+ // Playwright's actionability wait before it will click a menu item. The+ // second is not small — dispatching the same click in-page instead cut the+ // gap from 272.9ms to 25.8ms, so roughly 40% of the recorded layout switch+ // was the driver deciding the item was safe to click. A real click is still+ // used here; only the waiting is excluded, by moving the start of the+ // interval to the pointer event itself.+ await presetTrigger.click();+ const presetItem = page.getByRole('menuitem', { exact: true, name: fixture.layoutPreset });+ await presetItem.waitFor({ timeout: 10_000 });await page.evaluate(({ interactionMarkName, readyMark }) => {performance.clearMarks(interactionMarkName);performance.clearMarks(readyMark);- performance.mark(interactionMarkName);+ // Capture-phase and document-level, so this cannot miss the way matching+ // on a menu item's text could. The next pointerdown is the selection.+ document.addEventListener(+ 'pointerdown',+ () => {+ performance.mark(interactionMarkName);+ },+ { capture: true, once: true }+ );},{ interactionMarkName: interactionMark, readyMark: fixture.readyMark });- await presetTrigger.click();- await page.getByRole('menuitem', { exact: true, name: fixture.layoutPreset }).click();+ await presetItem.click();await page.getByRole('button', { exact: true, name: `Layout preset: ${fixture.layoutPreset}` }).waitFor({ timeout: 10_000 });await waitForSemanticMark(page, fixture.readyMark);layoutSwitchMs = await page.evaluate(({ interactionMarkName, readyMark }) => {- const start = performance.getEntriesByName(interactionMarkName, 'mark').at(-1)?.startTime ?? 0;- const end = performance.getEntriesByName(readyMark, 'mark').at(-1)?.startTime ?? 0;- return Math.max(0, end - start);+ const start = performance.getEntriesByName(interactionMarkName, 'mark').at(-1);+ const end = performance.getEntriesByName(readyMark, 'mark').at(-1);++ // A missing start mark used to read as 0 and silently turn the whole+ // interval into "time since navigation", which looks like a plausible+ // number rather than a broken one.+ return start && end ? Math.max(0, end.startTime - start.startTime) : null;},{ interactionMarkName: interactionMark, readyMark: fixture.readyMark });+ if (layoutSwitchMs === null) {+ throw new Error(`${fixture.id}/${fixture.stateProfile} did not record a layout-switch interaction.`);+ }const afterActivation = await resourceCollector.settle();activatedResourcePaths = new Set(afterActivation.filter((resource) => !beforePaths.has(resource.path)).map((resource) => resource.path)