Skip to content

fix(loader): stream HTML chunks incrementally with benchmark coverage#3145

Merged
kuitos merged 7 commits into
nextfrom
codex/benchmark-streaming-optimization
Jul 12, 2026
Merged

fix(loader): stream HTML chunks incrementally with benchmark coverage#3145
kuitos merged 7 commits into
nextfrom
codex/benchmark-streaming-optimization

Conversation

@kuitos

@kuitos kuitos commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

  • add a dedicated qiankun vs Wujie loading benchmark with six representative cells, A/A calibration, balanced ordering, paired bootstrap confidence intervals, and raw sample retention
  • add reproducible baseline bundle snapshots plus interleaved baseline/candidate revision comparison
  • make TagTransformStream flush safe HTML immediately while retaining only a possible cross-chunk tag prefix

Root cause

TagTransformStream previously enqueued data only when a <head> replacement changed the current buffer. Once the structural head had already been replaced, later chunks containing the micro-app core had no replacement and remained buffered until EOF. This defeated incremental HTML delivery.

The new scanner consumes each structural replacement once across the stream, preserves later matching literals in script raw text, rejects ambiguous replacement patterns, and keeps the pending buffer bounded by the longest unconsumed tag prefix.

Performance

Formal interleaved comparison, 100 valid samples per revision:

Baseline Candidate
median 141.70 ms 87.15 ms
p95 152.70 ms 98.20 ms

Paired relative delta: -38.52%, bootstrap 95% CI [-39.36%, -37.06%].

A/A calibration passed at +0.29%, 95% CI [-0.17%, +0.81%]. There were no invalid samples.

Validation

  • pnpm --filter @qiankunjs/loader test
  • relevant package tests: 172 passed
  • loader stream tests: 7 passed
  • deterministic chunk-boundary fuzzing: 40,000 valid random splits with no counterexample
  • pnpm run eslint
  • package builds and six-cell browser smoke matrix
  • pnpm run benchmark:compare

The repository-wide pnpm test reached the unrelated bundler-plugin webpack fixture, then stopped because the execution environment did not provide the system npm binary; all affected loader/shared/sandbox tests passed independently.

@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 32ee3b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kuitos
kuitos marked this pull request as ready for review July 12, 2026 14:00
@kuitos
kuitos merged commit dc274f8 into next Jul 12, 2026
6 checks passed
@kuitos
kuitos deleted the codex/benchmark-streaming-optimization branch July 12, 2026 15:48
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.

1 participant