-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(generation): parallelize scene content on the server path#698
Open
ly-wang19 wants to merge 1 commit into
Open
feat(generation): parallelize scene content on the server path #698ly-wang19 wants to merge 1 commit into
ly-wang19 wants to merge 1 commit into
Conversation
Follow-up to THU-MAIC#660, which parallelized scene-content generation on the client (useSceneGenerator). The server path (classroom-generation.ts, used by /api/generate-classroom + the background job-runner) was still strictly serial. Mirror THU-MAIC#660's pipeline: pre-warm scene content with bounded concurrency (reusing the server getParallelSceneConcurrency() helper + lazyBoundedMap, both from THU-MAIC#660), keep actions + scene assembly + progress reporting serial so scenes stay in outline order. Gated by the same PARALLEL_SCENE_CONCURRENCY env; default 0/unset is byte-for-byte the original serial pipeline. A content failure resolves to undefined and is skipped per-scene as before. Closes THU-MAIC#697
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.
What & why
Follow-up to #660 (merged), which added opt-in parallel scene-content generation to the client path. The server path —
lib/server/classroom-generation.ts, used by/api/generate-classroomand the background job-runner — was still strictly serial (for ... of outlines→await generateSceneContent→await generateSceneActions), so server-side / background generations got none of #660’s speedup. #572 listed this as the explicit "adopt the same pattern later" item.Closes #697.
Change
Mirror #660’s pipeline on the server:
lazyBoundedMap, reusing the server-sidegetParallelSceneConcurrency()helper (both added in feat(generation): opt-in parallel scene-content generation #660 ).onProgressreporting, so scenes stay in outline order and progress events fire in order.Properties:
PARALLEL_SCENE_CONCURRENCYenv. Default0/unset is byte-for-byte the original serial pipeline.undefinedand is skipped per-scene exactly as today (the parallel callback also catches throws →undefined, so one bad scene never aborts the batch).Test plan
npx vitest run— 742 tests pass;tsc/prettier/eslintclean. The concurrency mechanism is already unit-tested (tests/utils/concurrency.test.ts); the serial default path is unchanged. (classroom-generation.tsorchestrates LLM/IO and has no existing unit test — same as the rest of the server pipeline.)No user-facing strings (no i18n impact).