Commit dccdb6f
[Serve] limit num_workers in replica's ThreadPoolExecutor to num_cpus (ray-project#60271)
## Description
- Limit the user-code event loop’s default ThreadPoolExecutor size to
the deployment’s ray_actor_options["num_cpus"] (fractional values round
up, <=0 leaves
defaults).
- This ensures asyncio.to_thread in Serve replicas respects the CPU
reservation and avoids oversubscription.
- Added a Serve test that verifies the default executor’s max_workers
matches num_cpus.
## Related issues
> Link related issues: "Fixes ray-project#59750 ", "Closes ray-project#59750 ", or "Related to
ray-project#59750 ".
## Additional information
- Tests run:
- python -m pytest
python/ray/serve/tests/unit/test_user_callable_wrapper.py
- python -m pytest python/ray/serve/tests/test_replica_sync_methods.py
---------
Signed-off-by: yaommen <myanstu@163.com>
Signed-off-by: jinbum-kim <jinbum9958@gmail.com>1 parent eb3f89f commit dccdb6f
File tree
6 files changed
+93
-2
lines changed- doc/source/serve
- advanced-guides
- doc_code
- python/ray/serve
- _private
- tests
- unit
6 files changed
+93
-2
lines changedLines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
92 | 105 | | |
93 | 106 | | |
94 | 107 | | |
| |||
331 | 344 | | |
332 | 345 | | |
333 | 346 | | |
334 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
335 | 354 | | |
336 | 355 | | |
337 | 356 | | |
| |||
389 | 408 | | |
390 | 409 | | |
391 | 410 | | |
392 | | - | |
| 411 | + | |
393 | 412 | | |
394 | 413 | | |
395 | 414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
635 | 636 | | |
636 | 637 | | |
637 | 638 | | |
| 639 | + | |
638 | 640 | | |
639 | 641 | | |
640 | 642 | | |
| |||
1692 | 1694 | | |
1693 | 1695 | | |
1694 | 1696 | | |
| 1697 | + | |
1695 | 1698 | | |
1696 | 1699 | | |
1697 | 1700 | | |
| |||
1715 | 1718 | | |
1716 | 1719 | | |
1717 | 1720 | | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
1718 | 1725 | | |
1719 | 1726 | | |
1720 | 1727 | | |
| |||
1740 | 1747 | | |
1741 | 1748 | | |
1742 | 1749 | | |
| 1750 | + | |
1743 | 1751 | | |
1744 | 1752 | | |
1745 | 1753 | | |
| |||
1752 | 1760 | | |
1753 | 1761 | | |
1754 | 1762 | | |
| 1763 | + | |
1755 | 1764 | | |
1756 | 1765 | | |
1757 | 1766 | | |
1758 | 1767 | | |
1759 | 1768 | | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1760 | 1785 | | |
1761 | 1786 | | |
1762 | 1787 | | |
| |||
2477 | 2502 | | |
2478 | 2503 | | |
2479 | 2504 | | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
129 | 151 | | |
130 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
0 commit comments