From 0a5392dc744fc52d72b8ed19354fcc812bfbdd76 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 10 Oct 2026 01:54:07 -0400 Subject: [PATCH] fix: reduce batch size for importing pages from 2.x --- frontend/src/helpers/wkbackupImport.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/helpers/wkbackupImport.js b/frontend/src/helpers/wkbackupImport.js index 7825bc351..866c29135 100644 --- a/frontend/src/helpers/wkbackupImport.js +++ b/frontend/src/helpers/wkbackupImport.js @@ -14,6 +14,13 @@ import { inBatches, openPackage, readBytes, readJson, readRecords, sha256Hex } f /** Records per request. The server's own ceiling — see `MAX_BATCH_RECORDS` in `models/import.ts`. */ const BATCH_SIZE = 500 +/** + * Records per request for pages, the slow stream by far. A full batch of 500 has taken a minute on a + * large wiki — which is the ceiling a good many reverse proxies put on a request — where every other + * stream finishes one in a quarter of that. + */ +const PAGES_BATCH_SIZE = 250 + /** * What a batch aims to weigh, in UTF-16 code units of JSON. * @@ -54,7 +61,7 @@ const INSTANCE_STREAMS = [ const SITE_STREAMS = [ { name: 'tree', requires: null }, - { name: 'pages', requires: 'pages' }, + { name: 'pages', requires: 'pages', batchSize: PAGES_BATCH_SIZE }, { name: 'page-history', requires: 'history' }, { name: 'assets', requires: 'assets' }, { name: 'comments', requires: 'comments' } @@ -188,7 +195,7 @@ async function writeSteps({ pkg, plan, session, siteId, log, advance }) { readRecords(pkg.entry(step.path), { onMalformed: () => log('warn', `${label}: a record could not be read and was skipped.`) }), - { maxRecords: BATCH_SIZE, maxBytes: BATCH_BYTES } + { maxRecords: step.batchSize ?? BATCH_SIZE, maxBytes: BATCH_BYTES } )) { read += batch.length await stageBlobsFor({ pkg, session, batch, staged, log }) @@ -277,7 +284,7 @@ function buildPlan({ manifest, packageSite, includes, log }) { }) } - for (const { name, requires } of SITE_STREAMS) { + for (const { name, requires, batchSize } of SITE_STREAMS) { const declared = packageSite.streams?.[name] if (!declared?.path || (requires && !includes.includes(requires))) { continue @@ -287,6 +294,7 @@ function buildPlan({ manifest, packageSite, includes, log }) { label: labelFor(name), path: declared.path, count: declared.count ?? null, + batchSize, url: (session, siteId) => `import/sessions/${session.id}/sites/${siteId}/streams/${name}` }) }