Repository navigation
Commit ad826e4
perf: let metadata and section-pages start on their dependency's first chunk (#1240)
* perf: let metadata and section-pages start on their dependency's first chunk
With more than one thread, metadata and section-pages now start on the
first chunk of their dependency instead of waiting for all of it, so
parsing, metadata and section pages overlap. The generated files are
unchanged.
section-pages passes each module's entries on as they arrive and adds
the chunk pages after the last of them, in module order, as if built
from the whole input at once. A module's chunk pages need all of its
entries, and a chunk need not hold whole modules, so groupWholeModules
regroups streamed entries into batches of whole modules, and rejects a
module whose entries come back after another's.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Sonnet 5.5 <noreply@anthropic.com>
* docs: mention toBatches in the changeset, as it comes with groupWholeModules
worker.stream no longer reads its input with toBatches, so the helper
now comes with groupWholeModules, its first caller.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
* refactor: drop groupWholeModules, as metadata's chunks hold whole modules
From the review. A module is one file: parseApiDoc sets every entry's
api once per file, and worker.stream never splits an item, so each of
metadata's chunks already holds whole modules. section-pages reads its
input as it comes with toBatches instead of regrouping it, and the
helper and its tests go.
Co-authored-by: Aviv Keller <me@aviv.sh>
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
* test: check the streamed section pages without copies of what core has
The two tests comparing section-pages' batched output with its whole
input become one: both compared against the same output. core's
collectAsyncGenerator replaces a local copy of it, and html's test gives
section-pages its entries as an array, which it reads as one batch, so
it needs no stream of its own. toBatches' test no longer defines a
generator body it never runs. The comment on section-pages' chunk pages
says batches, as chunk already means a page there.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
* docs: point generators that stream their input to toBatches
Every streaming generator reads its input through toBatches, which
takes both the stream and the collected array one thread gives, but the
docs for writing one only said to accept both.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
* refactor: always give a generator that streams its input an async iterable
From the review, which asked for it. With one thread the input is still
collected first, as interleaving the stages there would only keep
every stage's data alive at once, but it now arrives as its only chunk
instead of as the array. A generator that sets streamsInput reads its
input with one for await either way, so toBatches goes, and the types
take only the async iterable.
core's once, which the cache already used to stream a result that
doesn't, moves to utils/generators.mjs next to the other generator
helpers. The test of one thread reads a source of two chunks, so it
shows they arrive as one.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Aviv Keller <me@aviv.sh>1 parent 41920cb commit ad826e4
16 files changed
Lines changed: 204 additions & 47 deletions
File tree
- .changeset
- docs
- packages
- core/src
- __tests__
- generators
- metadata
- utils
- __tests__
- react/src
- html/__tests__
- section-pages
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
| 345 | + | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
145 | 155 | | |
146 | 156 | | |
147 | | - | |
| 157 | + | |
148 | 158 | | |
149 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
| |||
339 | 353 | | |
340 | 354 | | |
341 | 355 | | |
342 | | - | |
| 356 | + | |
343 | 357 | | |
344 | 358 | | |
345 | 359 | | |
| |||
349 | 363 | | |
350 | 364 | | |
351 | 365 | | |
352 | | - | |
353 | | - | |
| 366 | + | |
| 367 | + | |
354 | 368 | | |
355 | 369 | | |
356 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 41 | | |
52 | 42 | | |
53 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | | - | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
| |||
76 | 92 | | |
77 | 93 | | |
78 | 94 | | |
79 | | - | |
80 | | - | |
81 | 95 | | |
82 | 96 | | |
83 | | - | |
| 97 | + | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
0 commit comments