Uh oh!
There was an error while loading. Please reload this page.
Commit 67688cc
stream: hoist repeated loads in readable paths
fromList() re-read state.length and each chunk's length several times
per call and re-loaded buffer[idx] around every copy, and read() loaded
state.length three times in its read(0) check; the engine cannot fold
these loads across the intervening copy and slice calls. Cache them in
locals instead. Ported from Bun's fork of the same functions
(src/js/internal/streams/readable.ts fromList/read), which carries
these hoists on top of the shared readable-stream lineage.
benchmark/compare.js against the unmodified baseline (60-run capture
plus an independent 30-run repeat, Welch t-test):
streams/readable-unevenread +0.65% (p=4.3e-4) / +0.59% (p=5.9e-3) and
streams/pipe.js +0.74% (p=2.0e-4) / +0.52% (p=8.8e-3), with no
significant regression across the captured streams benchmarks.
Refs: https://github.com/oven-sh/bun/blob/main/src/js/internal/streams/readable.ts
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Assisted-by: Grok (Grok Build)
PR-URL: #64312
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 6851b8d commit 67688cc
1 file changed
Lines changed: 61 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
676 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
677 | 679 | | |
678 | 680 | | |
679 | 681 | | |
680 | | - | |
681 | | - | |
| 682 | + | |
| 683 | + | |
682 | 684 | | |
683 | 685 | | |
684 | | - | |
| 686 | + | |
685 | 687 | | |
686 | 688 | | |
687 | 689 | | |
| |||
1624 | 1626 | | |
1625 | 1627 | | |
1626 | 1628 | | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1627 | 1635 | | |
1628 | | - | |
| 1636 | + | |
1629 | 1637 | | |
1630 | 1638 | | |
1631 | 1639 | | |
| |||
1637 | 1645 | | |
1638 | 1646 | | |
1639 | 1647 | | |
1640 | | - | |
| 1648 | + | |
1641 | 1649 | | |
1642 | 1650 | | |
1643 | 1651 | | |
| |||
1651 | 1659 | | |
1652 | 1660 | | |
1653 | 1661 | | |
1654 | | - | |
| 1662 | + | |
1655 | 1663 | | |
1656 | 1664 | | |
1657 | 1665 | | |
1658 | | - | |
1659 | | - | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
1660 | 1669 | | |
1661 | 1670 | | |
1662 | 1671 | | |
1663 | | - | |
1664 | | - | |
1665 | | - | |
1666 | | - | |
1667 | | - | |
1668 | | - | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
1679 | | - | |
1680 | | - | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
1681 | 1689 | | |
| 1690 | + | |
1682 | 1691 | | |
1683 | 1692 | | |
1684 | | - | |
1685 | | - | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
1686 | 1701 | | |
1687 | | - | |
1688 | 1702 | | |
1689 | | - | |
1690 | | - | |
1691 | | - | |
1692 | | - | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
1701 | | - | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
1702 | 1711 | | |
| 1712 | + | |
1703 | 1713 | | |
1704 | 1714 | | |
1705 | | - | |
1706 | | - | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1707 | 1723 | | |
1708 | | - | |
1709 | 1724 | | |
1710 | 1725 | | |
1711 | 1726 | | |
| |||
0 commit comments