Skip to content

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.

perf(projects): measure switch commits

Josh Corbett5fe42f0d6cac
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index 1c3a1bbd17..18fe5a7c7e 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": 148.10000000149012,
+ "domContentLoadedMedianMs": 151.20000000298023,
"id": "launchpad",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 148.10000000149012,
- "longestTaskMaxMs": 95,
+ "loadMedianMs": 151.30000000074506,
+ "longestTaskMaxMs": 99,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -39,24 +39,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 30,
- "scriptRawBytes": 1586951,
+ "scriptRawBytes": 1588375,
"scriptRequestCount": 26,
- "totalRawBytes": 1738946
+ "totalRawBytes": 1740736
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 30,
- "scriptRawBytes": 1602821,
+ "scriptRawBytes": 1604259,
"scriptRequestCount": 26,
- "totalRawBytes": 1756336
+ "totalRawBytes": 1758144
},
- "routeReadyMedianMs": 340.7000000011176,
+ "routeReadyMedianMs": 340.20000000298023,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -83,11 +83,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 148.90000000037253,
+ "domContentLoadedMedianMs": 155.69999999925494,
"id": "launchpad",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 148.90000000037253,
- "longestTaskMaxMs": 94,
+ "loadMedianMs": 155.79999999701977,
+ "longestTaskMaxMs": 98,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -97,24 +97,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 30,
- "scriptRawBytes": 1586951,
+ "scriptRawBytes": 1588375,
"scriptRequestCount": 26,
- "totalRawBytes": 1738946
+ "totalRawBytes": 1740736
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 30,
- "scriptRawBytes": 1602821,
+ "scriptRawBytes": 1604259,
"scriptRequestCount": 26,
- "totalRawBytes": 1756336
+ "totalRawBytes": 1758144
},
- "routeReadyMedianMs": 362.3999999985099,
+ "routeReadyMedianMs": 380.70000000298023,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -141,13 +141,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 154.2000000011176,
+ "domContentLoadedMedianMs": 157,
"id": "editor-minimal",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 154.30000000074506,
- "longestTaskMaxMs": 139,
+ "loadMedianMs": 157,
+ "longestTaskMaxMs": 159,
"owner": "workbench",
- "projectSwitchMedianMs": 303.8221630000007,
+ "projectSwitchMedianMs": 44.599999997764826,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -155,24 +155,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 770.5,
+ "routeReadyMedianMs": 754,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -199,13 +199,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 150.5,
+ "domContentLoadedMedianMs": 152,
"id": "editor-minimal",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 150.5,
- "longestTaskMaxMs": 168,
+ "loadMedianMs": 152,
+ "longestTaskMaxMs": 174,
"owner": "workbench",
- "projectSwitchMedianMs": 367.72414299999946,
+ "projectSwitchMedianMs": 76.10000000149012,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -213,24 +213,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 829.5999999996275,
+ "routeReadyMedianMs": 842.1999999992549,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -257,11 +257,11 @@
"scriptRequestCount": 4,
"totalRawBytes": 280504
},
- "domContentLoadedMedianMs": 148.7000000011176,
+ "domContentLoadedMedianMs": 150.09999999776483,
"id": "editor-canvas",
- "layoutSwitchMedianMs": 72.19999999925494,
- "loadMedianMs": 148.80000000074506,
- "longestTaskMaxMs": 143,
+ "layoutSwitchMedianMs": 76.30000000074506,
+ "loadMedianMs": 150.19999999925494,
+ "longestTaskMaxMs": 199,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -271,24 +271,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 107,
- "scriptRawBytes": 3558671,
+ "scriptRawBytes": 3559943,
"scriptRequestCount": 101,
- "totalRawBytes": 3882455
+ "totalRawBytes": 3884093
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 107,
- "scriptRawBytes": 3594258,
+ "scriptRawBytes": 3595543,
"scriptRequestCount": 101,
- "totalRawBytes": 3921280
+ "totalRawBytes": 3922934
},
- "routeReadyMedianMs": 1308,
+ "routeReadyMedianMs": 1317.3999999985099,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -315,11 +315,11 @@
"scriptRequestCount": 4,
"totalRawBytes": 280504
},
- "domContentLoadedMedianMs": 154.2000000011176,
+ "domContentLoadedMedianMs": 155.80000000074506,
"id": "editor-canvas",
- "layoutSwitchMedianMs": 260.09999999962747,
- "loadMedianMs": 154.2000000011176,
- "longestTaskMaxMs": 551,
+ "layoutSwitchMedianMs": 270.4000000022352,
+ "loadMedianMs": 155.90000000223517,
+ "longestTaskMaxMs": 565,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -329,24 +329,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 107,
- "scriptRawBytes": 3558671,
+ "scriptRawBytes": 3559943,
"scriptRequestCount": 101,
- "totalRawBytes": 3882455
+ "totalRawBytes": 3884093
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 107,
- "scriptRawBytes": 3594258,
+ "scriptRawBytes": 3595543,
"scriptRequestCount": 101,
- "totalRawBytes": 3921280
+ "totalRawBytes": 3922934
},
- "routeReadyMedianMs": 1643,
+ "routeReadyMedianMs": 1665.5,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -373,11 +373,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 147.7000000011176,
+ "domContentLoadedMedianMs": 154.60000000149012,
"id": "editor-workflow",
- "layoutSwitchMedianMs": 97.30000000074506,
- "loadMedianMs": 147.80000000074506,
- "longestTaskMaxMs": 141,
+ "layoutSwitchMedianMs": 86.69999999925494,
+ "loadMedianMs": 154.60000000149012,
+ "longestTaskMaxMs": 149,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -387,24 +387,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 1298.8999999985099,
+ "routeReadyMedianMs": 1328.3999999985099,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -431,11 +431,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 149.7999999988824,
+ "domContentLoadedMedianMs": 157.79999999701977,
"id": "editor-workflow",
- "layoutSwitchMedianMs": 158.90000000037253,
- "loadMedianMs": 149.89999999850988,
- "longestTaskMaxMs": 544,
+ "layoutSwitchMedianMs": 160.5,
+ "loadMedianMs": 157.79999999701977,
+ "longestTaskMaxMs": 574,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -445,24 +445,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 1495.8999999985099,
+ "routeReadyMedianMs": 1552.0999999977648,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -489,11 +489,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 153,
+ "domContentLoadedMedianMs": 158.5,
"id": "editor-gallery",
- "layoutSwitchMedianMs": 40.20000000111759,
- "loadMedianMs": 153,
- "longestTaskMaxMs": 144,
+ "layoutSwitchMedianMs": 39.5,
+ "loadMedianMs": 158.5,
+ "longestTaskMaxMs": 163,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -503,24 +503,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 1559.0999999996275,
+ "routeReadyMedianMs": 1634.5,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -547,11 +547,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 150.2999999988824,
+ "domContentLoadedMedianMs": 174.80000000074506,
"id": "editor-gallery",
- "layoutSwitchMedianMs": 129.10000000149012,
- "loadMedianMs": 150.40000000037253,
- "longestTaskMaxMs": 202,
+ "layoutSwitchMedianMs": 140.10000000149012,
+ "loadMedianMs": 174.90000000223517,
+ "longestTaskMaxMs": 217,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -561,24 +561,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746170,
- "otherRawBytes": 126172,
+ "otherRawBytes": 126538,
"requestCount": 103,
- "scriptRawBytes": 3280945,
+ "scriptRawBytes": 3282217,
"scriptRequestCount": 97,
- "totalRawBytes": 3604729
+ "totalRawBytes": 3606367
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753632,
- "otherRawBytes": 127434,
+ "otherRawBytes": 127804,
"requestCount": 103,
- "scriptRawBytes": 3313755,
+ "scriptRawBytes": 3315040,
"scriptRequestCount": 97,
- "totalRawBytes": 3640777
+ "totalRawBytes": 3642431
},
- "routeReadyMedianMs": 1827.5,
+ "routeReadyMedianMs": 2000.7000000029802,
"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.mjs
index b058c2f266..abadf502c4 100644
--- a/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs
+++ b/invokeai/frontend/webv2/scripts/measure-architecture-performance.mjs
@@ -386,20 +386,79 @@ const runSample = async (browser, fixture, sample) => {
}
await projectSwitcher.click();
+ const newProjectSave = page.waitForResponse(
+ (response) =>
+ response.request().method() === 'POST' && new URL(response.url()).pathname === '/api/v1/projects/',
+ { timeout: 10_000 }
+ );
await page.getByRole('menuitem', { exact: true, name: /new project/i }).click();
await page.waitForFunction(
(name) => document.querySelector('button[aria-label^="Switch project."]')?.textContent?.trim() !== name,
originalProjectName
);
+ // A new tab is server-backed on its first autosave. Let that response assign its board and
+ // reach a paint before timing the unrelated switch back; otherwise the sample randomly
+ // includes the reconciliation depending on where the 500 ms autosave lands.
+ const newProjectSaveResponse = await newProjectSave;
+ await newProjectSaveResponse.finished();
+ await page.evaluate(
+ () =>
+ new Promise((resolvePaint) => {
+ requestAnimationFrame(() => requestAnimationFrame(resolvePaint));
+ })
+ );
await projectSwitcher.click();
const originalProject = page.getByRole('menuitemradio').filter({ hasText: originalProjectName });
await originalProject.waitFor({ timeout: 10_000 });
- const projectSwitchStart = performance.now();
+ const projectSwitchInteractionMark = `invokeai:interaction:${fixture.id}:${fixture.stateProfile}:project-switch`;
+ const projectSwitchReadyMark = `invokeai:ready:${fixture.id}:${fixture.stateProfile}:project-switch`;
+ await page.evaluate(
+ ({ interactionMarkName, originalName, readyMarkName }) => {
+ performance.clearMarks(interactionMarkName);
+ performance.clearMarks(readyMarkName);
+
+ const projectSwitcher = document.querySelector('button[aria-label^="Switch project."]');
+ if (!projectSwitcher) {
+ throw new Error('Project switcher trigger is missing.');
+ }
+
+ const markReadyWhenProjectCommits = () => {
+ if (projectSwitcher.getAttribute('aria-label') !== `Switch project. Current project: ${originalName}`) {
+ return;
+ }
+
+ performance.mark(readyMarkName);
+ observer.disconnect();
+ };
+ const observer = new MutationObserver(markReadyWhenProjectCommits);
+ observer.observe(projectSwitcher, { attributes: true, childList: true, subtree: true });
+ document.addEventListener(
+ 'pointerdown',
+ () => {
+ performance.mark(interactionMarkName);
+ },
+ { capture: true, once: true }
+ );
+ },
+ {
+ interactionMarkName: projectSwitchInteractionMark,
+ originalName: originalProjectName,
+ readyMarkName: projectSwitchReadyMark,
+ }
+ );
await originalProject.click();
- await page
- .getByRole('button', { exact: true, name: `Switch project. Current project: ${originalProjectName}` })
- .waitFor({ timeout: 10_000 });
- projectSwitchMs = performance.now() - projectSwitchStart;
+ await waitForSemanticMark(page, projectSwitchReadyMark);
+ projectSwitchMs = await page.evaluate(
+ ({ interactionMarkName, readyMarkName }) => {
+ const start = performance.getEntriesByName(interactionMarkName, 'mark').at(-1);
+ const end = performance.getEntriesByName(readyMarkName, 'mark').at(-1);
+ return start && end ? Math.max(0, end.startTime - start.startTime) : null;
+ },
+ { interactionMarkName: projectSwitchInteractionMark, readyMarkName: projectSwitchReadyMark }
+ );
+ if (projectSwitchMs === null) {
+ throw new Error(`${fixture.id}/${fixture.stateProfile} did not record a project-switch interaction.`);
+ }
}
await waitForWidgetRequests(fixture, scripts);