Skip to content

feat(generation): parallelize scene content on the server path#698

Open
ly-wang19 wants to merge 1 commit into
THU-MAIC:mainfrom
ly-wang19:feat/parallel-server-scene-content
Open

feat(generation): parallelize scene content on the server path#698
ly-wang19 wants to merge 1 commit into
THU-MAIC:mainfrom
ly-wang19:feat/parallel-server-scene-content

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

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-classroom and the background job-runner — was still strictly serial (for … of outlinesawait generateSceneContentawait 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:

  • Pre-warm scene content with bounded concurrency via lazyBoundedMap, reusing the server-side getParallelSceneConcurrency() helper (both added in feat(generation): opt-in parallel scene-content generation #660).
  • Keep the existing serial loop for actions + scene assembly + onProgress reporting, so scenes stay in outline order and progress events fire in order.

Properties:

  • Gated by the same PARALLEL_SCENE_CONCURRENCY env. Default 0/unset is byte-for-byte the original serial pipeline.
  • Content has no cross-scene dependency, so running it ahead is safe; a content failure resolves to undefined and 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 run742 tests pass; tsc/prettier/eslint clean. The concurrency mechanism is already unit-tested (tests/utils/concurrency.test.ts); the serial default path is unchanged. (classroom-generation.ts orchestrates LLM/IO and has no existing unit test — same as the rest of the server pipeline.)

No user-facing strings (no i18n impact).

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
@ly-wang19 ly-wang19 force-pushed the feat/parallel-server-scene-content branch from 92531f6 to 2e414b2 Compare June 15, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply parallel scene-content generation to the server path (follow-up to #660)

1 participant