Repository navigation
Commit 1c97070
authored
fix: hand out a recorded hash update as buffers (#289)
* fix: hand out a recorded hash update as buffers
CachedSource.updateHash records what the wrapped source hashed so later
calls replay it. Since 3.5.2 a string-backed source hashes its string, so
the recording keeps that string, and getCachedData() handed it to callers
that serialize it — webpack's pack warns "Serializing big strings" and
pays for it on every deserialization.
Encode the strings as buffers in getCachedData(), the boundary a caller
serializes from, so the recording still holds the source's own string and
nothing copies it until it is written out. Hashing reads a string as utf8,
so the restored update hashes to the same digest.
* Encode the recorded hash update once, in place
The first version rebuilt the buffered array on every getCachedData()
call, so a source serialized more than once was re-encoded each time:
+19.7MB of buffer allocation over the css/large fixture's cache build.
Encode in place instead. A source nobody asks cached data of still keeps
its own string uncopied, and one that is handed out repeatedly is encoded
once.1 parent 6f9c00e commit 1c97070
3 files changed
Lines changed: 55 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
59 | 78 | | |
60 | 79 | | |
61 | 80 | | |
| |||
209 | 228 | | |
210 | 229 | | |
211 | 230 | | |
212 | | - | |
| 231 | + | |
213 | 232 | | |
214 | 233 | | |
215 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
640 | 670 | | |
0 commit comments