Repository navigation
Conversation
`extractBatch(rows, package, singleCss, importMainCssInCode, importMainCssInCss, aliases, sourceMap, threads?)` extracts [filename, code, cssDir] rows and returns, for each, the output codeExtract would give without CSS or the Error its source failed with. The native engine runs the core batch on worker threads (by default the cores, at most eight; more only queue on the resolver), calling the module resolver on the JS thread. The WASM engine extracts the rows one by one, so both engines keep one ABI. The argument validator, ABI name lists and the native/WASM parity corpus learn the new export; a corpus scenario compares the batch on both engines with every resolver answer, and a private native check covers a resolver that throws past the adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…I check Name the WASM threads parameter like the native one, so the ABI coverage pairs it with its validation case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The native consumer check and the compiler structural types test pin the number of engine exports; extractBatch adds one to each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
…binding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…binding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…binding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odegen again Holding each source's turn until its output was committed (acb9501) was correct but serialized code generation and the stylesheet commit: the large app's prewarm only went from 289 ms to about 200-230 ms. The turn passes at code generation again, and the batch commits on the calling thread in source order. What the commit would name first (global-bucket names of styles a source reaches through an import, for instance) is now named before the turn passes: the extractor walks the styles in the commit's order and scope (`name_as_committed`), so the commit only looks names up. Outside a batch the hook does nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…binding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ler passes The native adapter turned `threads` into a u32 with `>>> 0`, so -1 asked for 4,294,967,295 workers (one per source in practice), 2.5 for 2 and NaN for 0, and an explicit count was never capped at the default's eight. `threads` now reaches the core as a number, and `batch_threads` keeps a whole count from 1, capped at 8, and gives the default (the cores, at most 8) for none, 0, a negative, a fraction, NaN or an infinity. This follows the `n` argument convention: any number or null is accepted, and a count that makes no sense falls back like an `atomHoist` that does. The WASM engine reads `threads` as a number too and still extracts one by one. Covered by an rstest table in core, by the binding corpus that both engines run and compare, by the native private host calling the raw binding with those counts, and by a bun test through both engines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stack: #1113 (A, core) → this PR (B, binding) → C (Next plugin prewarm, on #1112). Based on #1113's branch.
Adds
extractBatchto both engines:Each result is what
codeExtract/codeExtractWithoutSourceMapwould return for that row, without CSS, or theErrorit would have thrown. Class names, CSS and the exported maps are the same as extracting the rows one by one in order.@devup-ui/binding): runs perf(binding): extract a batch on worker threads with in-order numbering #1113's core batch on worker threads.threadsdefaults to the number of cores, capped at 8: past about 4 the resolver on the JS thread is the bottleneck. The module resolver is still called on the JS thread only, once per(specifier, importer)per batch.@devup-ui/wasm): extracts the rows one by one through the same path ascodeExtract. Both engines keep one ABI, which the parity harness requires.DevupCompilermarksextractBatchoptional, so plugins can fall back on older engines.argument-validation.cjsvalidates the new arguments the same way on both engines. The ABI name lists, the export-count checks in the wasm post-build script, and the validation counts (56 → 64 positions) are updated.Tests
extract-batch-sources-in-order, compared byte for byte between native and WASM byidentity.mjs. It covers a resolver answering with a module, nothing, a throw and a malformed result; a broken source; source maps; explicit and default thread counts; the empty batch; a bad row; and no resolver.identity.mjs,validation.mjs(742 runs, 0 failed) andentries.mjs(node and bun × both engines) pass locally.wasm-abi.test.tspasses. Lint is clean.Micro benchmark (large Turbopack app, 334 files, real JS resolver, 7 runs, median): one by one 260 ms →
extractBatchat 2 threads 151 ms, 4 threads 130 ms, 8 threads 125 ms. Outputs and exported state were identical at every thread count.요약
스택: #1113 (A, 코어) → 이 PR (B, 바인딩) → C (Next 플러그인 prewarm, #1112 기반). #1113 브랜치 기반입니다.
두 엔진 모두에
extractBatch를 추가합니다.각 결과는 그 행에 대해
codeExtract/codeExtractWithoutSourceMap이 반환했을 출력(CSS 제외)이거나, 던졌을Error입니다. 클래스 이름, CSS, 내보낸 map은 행을 순서대로 하나씩 추출한 결과와 같습니다.@devup-ui/binding): #1113의 코어 배치를 워커 스레드에서 실행합니다.threads기본값은 코어 수이고 최대 8입니다. 약 4개를 넘으면 JS 스레드의 리졸버가 병목이 되기 때문입니다. 모듈 리졸버는 여전히 JS 스레드에서만, 배치 안에서(specifier, importer)마다 한 번 호출됩니다.@devup-ui/wasm):codeExtract와 같은 경로로 행을 하나씩 추출합니다. 패리티 하네스가 요구하는 대로 두 엔진의 ABI를 하나로 유지합니다.DevupCompiler에서extractBatch는 선택 항목이라서, 플러그인은 이전 엔진에서 기존 경로로 돌아갈 수 있습니다.argument-validation.cjs는 새 인자를 두 엔진에서 똑같이 검증합니다. ABI 이름 목록, wasm 빌드 후 스크립트의 export 개수 검사, 검증 개수(위치 56 → 64)도 갱신했습니다.테스트
extract-batch-sources-in-order를identity.mjs가 네이티브와 WASM 사이에서 바이트 단위로 비교합니다. 다루는 경우는 리졸버가 모듈을 돌려주거나, 아무것도 돌려주지 않거나, 예외를 던지거나, 잘못된 결과를 돌려주는 경우입니다. 깨진 소스, 소스맵, 명시한 스레드 수와 기본 스레드 수, 빈 배치, 잘못된 행, 리졸버 없음도 포함합니다. 로컬에서identity.mjs,validation.mjs(742회 실행, 실패 0),entries.mjs(node와 bun × 두 엔진)가 통과합니다.wasm-abi.test.ts가 통과하고 lint 경고가 없습니다.마이크로 벤치마크(대형 Turbopack 앱, 334개 파일, 실제 JS 리졸버, 7회 중앙값): 하나씩 260 ms →
extractBatch2 스레드 151 ms, 4 스레드 130 ms, 8 스레드 125 ms. 모든 스레드 수에서 출력과 내보낸 상태가 같았습니다.Fix after review: a valid thread count whatever the caller passes
The native adapter turned
threadsinto a u32 with>>> 0, so-1asked for 4,294,967,295 workers (one per source in practice),2.5for 2 andNaNfor 0. An explicit count also had no cap.threadsnow reaches the core as a number. A whole count from 1 is kept and capped at 8, like the default. Anything else (none, 0, a negative, a fraction,NaN, an infinity) gets the default: the cores, at most 8. This follows thenargument convention, so no count throws. The WASM engine reads it the same way and still extracts one by one. Tests: an rstest table in core, odd counts in the binding corpus both engines run and compare, raw native calls in the private host, and a bun test through both engines.리뷰 후 수정: 호출자가 무엇을 넘기든 올바른 스레드 수
네이티브 어댑터는
threads를>>> 0으로 u32로 바꿨습니다. 그래서-1은 워커 4,294,967,295개(실제로는 소스마다 하나),2.5는 2개,NaN은 0개를 요청했습니다. 명시한 수에는 상한도 없었습니다. 이제threads는 숫자 그대로 코어에 전달됩니다. 1 이상의 정수는 기본값처럼 최대 8로 제한해 그대로 쓰고, 그 밖의 값(없음, 0, 음수, 소수,NaN, 무한대)은 기본값(코어 수, 최대 8)을 씁니다.n인자 규칙을 따르므로 어떤 수도 예외를 던지지 않습니다. WASM 엔진도 같은 방식으로 읽고, 여전히 하나씩 추출합니다. 테스트: 코어의 rstest 표, 두 엔진이 실행해 비교하는 바인딩 corpus의 특이한 스레드 수, private host의 네이티브 직접 호출, 두 엔진을 거치는 bun 테스트.🤖 Generated with Claude Code