From 08ca482bcd53e045b821563e9640cff4f4c6d2be Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:32:34 +0900 Subject: [PATCH] chore(dev): tweak some workflows --- .github/scripts/frontend-js-size.mts | 67 +------------------------- .github/scripts/heap-snapshot-util.mts | 30 ++++-------- 2 files changed, 10 insertions(+), 87 deletions(-) diff --git a/.github/scripts/frontend-js-size.mts b/.github/scripts/frontend-js-size.mts index 1be657f9ef..7bbc19ce0b 100644 --- a/.github/scripts/frontend-js-size.mts +++ b/.github/scripts/frontend-js-size.mts @@ -476,67 +476,6 @@ function renderFrontendBundleReport(before: ReturnType) { - const rows = report.hotModules - .filter((row) => row.renderedLength > 0) - .slice(0, visualizerTreemapLimit); - const topRendered = rows.reduce((sum, row) => sum + row.renderedLength, 0); - const otherRendered = Math.max(0, report.metrics.renderedLength - topRendered); - const lines = [ - '```mermaid', - `%%{init: ${JSON.stringify({ - treemap: { - diagramPadding: 0, - padding: 0, - nodeHeight: 70, - }, - })}}%%`, - 'treemap-beta', - `"${mermaidTreemapLabel(label)}"`, - ]; - - for (const row of rows) { - lines.push(` "${mermaidTreemapModuleLabel(row.id)}": ${Math.round(row.renderedLength)}`); - } - if (otherRendered > 0) { - lines.push(` "Other": ${Math.round(otherRendered)}`); - } - - lines.push('```'); - return lines.join('\n'); -} - -function renderVisualizerTreemapDetails(label: string, report: ReturnType, open = false) { - return [ - ``, - `${label} rendered size treemap (top ${visualizerTreemapLimit} + Other)`, - '', - renderVisualizerTreemap(label, report), - '', - '', - ].join('\n'); -} - const args = process.argv.slice(2); const [beforeDir, afterDir, beforeStatsFile, afterStatsFile, outFile] = args; const before = await collectReport(beforeDir); @@ -545,7 +484,7 @@ const beforeStats = JSON.parse(await fs.readFile(beforeStatsFile, 'utf8')) as Vi const afterStats = JSON.parse(await fs.readFile(afterStatsFile, 'utf8')) as VisualizerReport; const beforeVisualizerReport = collectVisualizerReport(beforeStats); const afterVisualizerReport = collectVisualizerReport(afterStats); -const visualizerArtifactLink = `[Open detailed HTML](${process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL})`; +const visualizerArtifactLink = `[Open treemap HTML](${process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL})`; const body = [ marker, @@ -558,10 +497,6 @@ const body = [ '', renderFrontendBundleReport(beforeVisualizerReport, afterVisualizerReport), '', - renderVisualizerTreemapDetails('Before', beforeVisualizerReport), - '', - renderVisualizerTreemapDetails('After', afterVisualizerReport), - '', visualizerArtifactLink, ].join('\n'); diff --git a/.github/scripts/heap-snapshot-util.mts b/.github/scripts/heap-snapshot-util.mts index b941cbcfb1..00f8f0cb26 100644 --- a/.github/scripts/heap-snapshot-util.mts +++ b/.github/scripts/heap-snapshot-util.mts @@ -55,13 +55,7 @@ export type HeapSnapshotReport = { }; function getHeapSnapshotCategoryValue(report: HeapSnapshotReport, category: typeof heapSnapshotCategories[number]) { - const value = report.summary.categories[category]; - return Number.isFinite(value) ? value : null; -} - -function getHeapSnapshotCategoryValueFromSample(sample: HeapSnapshotReport['samples'][number], category: typeof heapSnapshotCategories[number]) { - const value = sample.data.categories[category]; - return Number.isFinite(value) ? value : null; + return report.summary.categories[category]; } export function renderHeapSnapshotTable(base: HeapSnapshotReport, head: HeapSnapshotReport) { @@ -72,17 +66,9 @@ export function renderHeapSnapshotTable(base: HeapSnapshotReport, head: HeapSnap const baseTotal = getHeapSnapshotCategoryValue(base, 'Total'); const headTotal = getHeapSnapshotCategoryValue(head, 'Total'); - function formatHeapSnapshotCategoryLabel(category: typeof heapSnapshotCategories[number], baseValue: number, headValue: number, baseTotal: number, headTotal: number) { - return `**${category}**`; - //if (category === 'Total') return `**${category}**`; - //const basePercent = util.formatPercent((baseValue * 100) / baseTotal); - //const headPercent = util.formatPercent((headValue * 100) / headTotal); - //return `**${category}**
${basePercent} → ${headPercent}`; - } - function getHeapSnapshotSampleSpread(report: HeapSnapshotReport, category: typeof heapSnapshotCategories[number]) { const values = report.samples - .map(sample => getHeapSnapshotCategoryValueFromSample(sample, category)) + .map(sample => sample.data.categories[category]) .filter(value => Number.isFinite(value)) as number[]; if (values.length < 2) throw new Error(`Not enough samples for category ${category}`); @@ -93,18 +79,20 @@ export function renderHeapSnapshotTable(base: HeapSnapshotReport, head: HeapSnap for (const category of heapSnapshotCategories) { const baseValue = getHeapSnapshotCategoryValue(base, category); const headValue = getHeapSnapshotCategoryValue(head, category); - if (baseValue == null || headValue == null) continue; - const baseSpread = getHeapSnapshotSampleSpread(base, category); const headSpread = getHeapSnapshotSampleSpread(head, category); - const summary = util.pairedDeltaSummary(base.samples, head.samples, (sample) => getHeapSnapshotCategoryValueFromSample(sample, category)); + const summary = util.pairedDeltaSummary(base.samples, head.samples, (sample) => sample.data.categories[category]); const percent = summary.median * 100 / baseValue; const deltaMedian = category === 'Total' ? `${util.formatDeltaBytes(summary.median)}
${util.formatDeltaPercent(percent).replaceAll('\\%', '\\\\%')}` : util.formatDeltaBytes(summary.median); const baseText = category === 'Total' ? `${util.formatBytes(baseValue)}
± ${util.formatBytes(baseSpread)}` : util.formatBytes(baseValue); const headText = category === 'Total' ? `${util.formatBytes(headValue)}
± ${util.formatBytes(headSpread)}` : util.formatBytes(headValue); - const categoryLabel = formatHeapSnapshotCategoryLabel(category, baseValue, headValue, baseTotal, headTotal); + const basePercent = util.formatPercent((baseValue * 100) / baseTotal); + const headPercent = util.formatPercent((headValue * 100) / headTotal); + const metricText = category === 'Total' + ? `$\\color{${heapSnapshotCategoriesColors[category]}}{\\rule{8pt}{8pt}}$ **${category}**` + : `
$\\color{${heapSnapshotCategoriesColors[category]}}{\\rule{8pt}{8pt}}$ **${category}**${basePercent} → ${headPercent}
`; - lines.push(`| $\\color{${heapSnapshotCategoriesColors[category]}}{\\rule{8pt}{8pt}}$ ${categoryLabel} | ${baseText} | ${headText} | ${deltaMedian} | ${util.formatBytes(summary.mad)} | ${util.formatDeltaBytes(summary.min)} | ${util.formatDeltaBytes(summary.max)} |`); + lines.push(`| ${metricText} | ${baseText} | ${headText} | ${deltaMedian} | ${util.formatBytes(summary.mad)} | ${util.formatDeltaBytes(summary.min)} | ${util.formatDeltaBytes(summary.max)} |`); if (category === 'Total') { lines.push('| | | | | | | |'); }