mars-project / mars-project/mars
Use direct async call for in-process rpc
@chaokunyang is already working on this.
Since Feb 9, 2022.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
Mars oscar actor uses at least one `asyncio.Task` for every actor call, which is expensive when there are thousands of tasks. `asyncio.Task` is about 100~200 slower than a normal async call, and the cost grows when there are more tasks in event loop. When there are hundreds of subtasks being schduled by the supervisor, there will be thousands of `asyncio.Task` in the event loop of supervisor, which make the supervisor as the bottleneck of the whole system.
**Describe the solution you'd like**
For in-process actor call, it's possible to use direct async function call. Instead of creating an new `asyncio.Task` to process the message, we can just use the `asyncio.Task` of the caller to handle the message, thus reduced all extra `asyncio.Task`.
**Additional context**
For `TellMessage`, it's executed in the background and there is not an easy way to avoid the `asyncio.Task`, so`TellMessage` should be used sparely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.