From e52e3906a5df7924585045d98c7e66f7e39a3930 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Tue, 17 Dec 2024 10:58:04 -0300 Subject: [PATCH] process bsc in batches --- tests/docstrings_examples/DocTest.res | 35 +++++++++++++++++------ tests/docstrings_examples/DocTest.res.mjs | 6 ++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tests/docstrings_examples/DocTest.res b/tests/docstrings_examples/DocTest.res index ce0721ac6d..15f59771df 100644 --- a/tests/docstrings_examples/DocTest.res +++ b/tests/docstrings_examples/DocTest.res @@ -325,15 +325,35 @@ let main = async () => { ->Array.map(f => extractDocFromFile(Path.join(["runtime", f]))->getExamples) ->Array.flat + let batchSize = OS.cpus()->Array.length + let compilationResults = - await modules - ->Array.map(async example => { - let id = example.id->String.replaceAll(".", "__") - let rescriptCode = example->getCodeBlocks - let jsCode = await compileTest(~id, ~code=rescriptCode) - (example, (rescriptCode, jsCode)) + (await modules + ->chunkArray(batchSize) + ->Array.map(async arrExample => { + await arrExample + ->Array.map(async example => { + let id = example.id->String.replaceAll(".", "__") + let rescriptCode = example->getCodeBlocks + let jsCode = await compileTest(~id, ~code=rescriptCode) + (example, (rescriptCode, jsCode)) + }) + ->Promise.all }) - ->Promise.all + ->Promise.all) + ->Array.flat + + // let _ = c > 1 + + // let compilationResults = + // await modules + // ->Array.map(async example => { + // let id = example.id->String.replaceAll(".", "__") + // let rescriptCode = example->getCodeBlocks + // let jsCode = await compileTest(~id, ~code=rescriptCode) + // (example, (rescriptCode, jsCode)) + // }) + // ->Promise.all let (compiled, compilationErrors) = compilationResults->Array.reduce(([], []), ( acc, @@ -347,7 +367,6 @@ let main = async () => { (lhs, rhs) }) - let batchSize = OS.cpus()->Array.length let batches = chunkArray(compiled, batchSize) let a = diff --git a/tests/docstrings_examples/DocTest.res.mjs b/tests/docstrings_examples/DocTest.res.mjs index 3486a83565..577cc10c9f 100644 --- a/tests/docstrings_examples/DocTest.res.mjs +++ b/tests/docstrings_examples/DocTest.res.mjs @@ -361,7 +361,8 @@ async function main() { return acc.concat([cur]); } }).map(f => getExamples(extractDocFromFile(Path.join("runtime", f)))).flat(); - let compilationResults = await Promise.all(modules.map(async example => { + let batchSize = Os.cpus().length; + let compilationResults = (await Promise.all(chunkArray(modules, batchSize).map(async arrExample => await Promise.all(arrExample.map(async example => { let id = example.id.replaceAll(".", "__"); let rescriptCode = getCodeBlocks(example); let jsCode = await compileTest(id, rescriptCode); @@ -372,7 +373,7 @@ async function main() { jsCode ] ]; - })); + }))))).flat(); let match = $$Array.reduce(compilationResults, [ [], [] @@ -402,7 +403,6 @@ async function main() { rhs ]; }); - let batchSize = Os.cpus().length; let batches = chunkArray(match[0], batchSize); let a = await Promise.all(batches.map(async t => $$Array.filterMap(await Promise.all(t.filter(param => !ignoreRuntimeTests.includes(param[0].id)).map(async param => { let jsCode = param[2];