Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support c++20 coroutine #2121

Merged
merged 7 commits into from
Jan 23, 2024
Merged

Support c++20 coroutine #2121

merged 7 commits into from
Jan 23, 2024

Conversation

wwbmmm
Copy link
Contributor

@wwbmmm wwbmmm commented Feb 10, 2023

What problem does this PR solve?

Issue Number:

Problem Summary: Support c++20 coroutine

What is changed and the side effects?

Changed: New feature

Side effects:

  • Performance effects(性能影响):

    • Use example/coroutine, start server with taskset -c 1 ./coroutine_server -enable_coroutine=1 -sleep_us=100, start rpc_press with ../../tools/rpc_press/rpc_press -proto=./echo.proto -method=example.EchoService.Proxy -input='{"message":"hello"}' -qps=0 -thread_num=100 -duration=0 -server=0.0.0.0:8000 -timeout_ms=2000 -connection_type=pooled, the result is :image
    • When start coroutine_server with -enable_coroutine=0, the result is :image
    • Conclusion: the coroutine version's performance is 70%+ better than the classical sync version.
  • Breaking backward compatibility(向后兼容性): No


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@chenzhangyi
Copy link
Member

@wwbmmm 你可以加一个文档大概说一下实现原理和使用方式么(和当前直接用bthread的区别和注意事项)

@wwbmmm
Copy link
Contributor Author

wwbmmm commented Feb 17, 2023

@wwbmmm 你可以加一个文档大概说一下实现原理和使用方式么(和当前直接用bthread的区别和注意事项)

好的

@wwbmmm
Copy link
Contributor Author

wwbmmm commented Feb 17, 2023

@wwbmmm 你可以加一个文档大概说一下实现原理和使用方式么(和当前直接用bthread的区别和注意事项)

已补充文档

@wwbmmm
Copy link
Contributor Author

wwbmmm commented Apr 17, 2023

加了experimental命名空间

@stdpain
Copy link
Contributor

stdpain commented Dec 28, 2023

如果调整系统的mmap_max_count,可以达到coroutine一样的效果吗

@wwbmmm
Copy link
Contributor Author

wwbmmm commented Jan 9, 2024

如果调整系统的mmap_max_count,可以达到coroutine一样的效果吗

这样只是增加了bthread数量的上限。但是bthread的堆栈内存占用、堆栈切换开销还是会比coroutine更大。

@wwbmmm wwbmmm merged commit 210ebfb into apache:master Jan 23, 2024
jiangdongzi pushed a commit to jiangdongzi/brpc that referenced this pull request Jan 31, 2024
* Support c++20 coroutine

* Fix CI UT failed

* Add example coroutine Makefile

* Add usercode_in_coroutine flag

* Add coroutine document

* Add experimental namespace for coroutine
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants