Uh oh!
There was an error while loading. Please reload this page.
Commit 1b0597b
stream: cut per-chunk allocations in pipeTo
readableStreamPipeTo allocated, for every chunk written to the
destination, a { promise, resolve, reject } write request record that
it immediately marked as handled, and drove its loop with an async
step()/run() pair whose implicit promises cost one allocation and one
reaction per iteration. The parked-read path additionally allocated a
read request object, a PromiseWithResolvers record, and a microtask
closure per chunk; this is the steady state for pipeThrough, since a
TransformStream's readable side has a high water mark of zero.
Replace the per-write records with a single per-pipe tracker that the
write request queue holds once per pending write and whose
resolve()/reject() methods maintain a pending-write count, drive the
pump loop with plain callbacks instead of async functions, and reuse
one read request and one forwarding function across all chunks, the
same pattern tee uses since c543cfb.
Benchmark results (benchmark/compare.js --runs 20):
webstreams/pipe-to.js +29.9% to +35.8% across all 16 configurations
(all 99.9% confidence); a pipeThrough(TransformStream) passthrough
loop improves ~17%; every other webstreams benchmark is unchanged.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64890
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>1 parent 718cbe9 commit 1b0597b
3 files changed
Lines changed: 310 additions & 65 deletions
File tree
- lib/internal/webstreams
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
| |||
139 | 135 | | |
140 | 136 | | |
141 | 137 | | |
142 | | - | |
| 138 | + | |
143 | 139 | | |
144 | 140 | | |
145 | 141 | | |
| |||
1530 | 1526 | | |
1531 | 1527 | | |
1532 | 1528 | | |
1533 | | - | |
1534 | | - | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
1535 | 1561 | | |
1536 | 1562 | | |
1537 | 1563 | | |
| |||
1548 | 1574 | | |
1549 | 1575 | | |
1550 | 1576 | | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
1556 | 1585 | | |
1557 | 1586 | | |
1558 | 1587 | | |
| |||
1561 | 1590 | | |
1562 | 1591 | | |
1563 | 1592 | | |
1564 | | - | |
| 1593 | + | |
1565 | 1594 | | |
1566 | 1595 | | |
1567 | 1596 | | |
| |||
1582 | 1611 | | |
1583 | 1612 | | |
1584 | 1613 | | |
1585 | | - | |
| 1614 | + | |
1586 | 1615 | | |
1587 | 1616 | | |
1588 | 1617 | | |
| |||
1639 | 1668 | | |
1640 | 1669 | | |
1641 | 1670 | | |
1642 | | - | |
1643 | | - | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
1644 | 1691 | | |
1645 | 1692 | | |
1646 | | - | |
1647 | | - | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
1648 | 1698 | | |
1649 | 1699 | | |
1650 | 1700 | | |
1651 | 1701 | | |
1652 | 1702 | | |
1653 | | - | |
1654 | | - | |
| 1703 | + | |
| 1704 | + | |
1655 | 1705 | | |
1656 | 1706 | | |
1657 | 1707 | | |
1658 | 1708 | | |
1659 | 1709 | | |
1660 | | - | |
| 1710 | + | |
1661 | 1711 | | |
1662 | 1712 | | |
1663 | 1713 | | |
| |||
1668 | 1718 | | |
1669 | 1719 | | |
1670 | 1720 | | |
1671 | | - | |
1672 | | - | |
| 1721 | + | |
1673 | 1722 | | |
1674 | 1723 | | |
1675 | 1724 | | |
| |||
1686 | 1735 | | |
1687 | 1736 | | |
1688 | 1737 | | |
1689 | | - | |
| 1738 | + | |
1690 | 1739 | | |
1691 | 1740 | | |
1692 | | - | |
1693 | | - | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
1694 | 1745 | | |
1695 | 1746 | | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
1701 | | - | |
1702 | | - | |
1703 | | - | |
1704 | | - | |
1705 | | - | |
1706 | | - | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
1707 | 1761 | | |
1708 | 1762 | | |
1709 | 1763 | | |
| |||
1715 | 1769 | | |
1716 | 1770 | | |
1717 | 1771 | | |
1718 | | - | |
| 1772 | + | |
1719 | 1773 | | |
1720 | 1774 | | |
1721 | 1775 | | |
| |||
1760 | 1814 | | |
1761 | 1815 | | |
1762 | 1816 | | |
1763 | | - | |
1764 | | - | |
1765 | | - | |
1766 | | - | |
1767 | | - | |
1768 | | - | |
1769 | | - | |
1770 | | - | |
1771 | | - | |
1772 | | - | |
1773 | | - | |
1774 | | - | |
1775 | | - | |
1776 | | - | |
1777 | | - | |
1778 | | - | |
1779 | | - | |
1780 | | - | |
1781 | | - | |
1782 | | - | |
1783 | | - | |
1784 | | - | |
1785 | | - | |
1786 | | - | |
1787 | | - | |
1788 | | - | |
1789 | | - | |
1790 | 1817 | | |
1791 | 1818 | | |
1792 | 1819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1004 | 1059 | | |
1005 | 1060 | | |
1006 | 1061 | | |
| |||
1376 | 1431 | | |
1377 | 1432 | | |
1378 | 1433 | | |
| 1434 | + | |
1379 | 1435 | | |
1380 | 1436 | | |
1381 | 1437 | | |
| |||
0 commit comments