-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any_executor_base::destroy_object and any_executor_base::copy_object high CPU usage #2892
Comments
Please make sure you are building the application in release mode. Boost.Beast and Boost.Asio have a lot of indirection and generic functions, which result in a very slow debug executable. You can eliminate the need for using tcp_stream = beast::basic_stream<
asio::ip::tcp,
asio::io_context::executor_type,
beast::unlimited_rate_policy>; or if you are using a strand: using tcp_stream = beast::basic_stream<
asio::ip::tcp,
asio::strand<asio::io_context::executor_type>,
beast::unlimited_rate_policy>; However, given your load (250 connections, 20 req/s each), this seems an unnecessary optimization. What is your total CPU usage for running your application? |
@ashtum Your code suggestion is not friend with my code.
|
100% CPU usage for 5k messages/second is unusual; you can typically expect around 50k on a single core (assuming no other tasks are consuming significant processing power). I believe compiling without debug symbols won't help much. What CPU usage do you observe when running it on your desktop?
You need to use concrete executor types for
However, as I mentioned, this change won't make your code significantly faster, expect around a 5% improvement at most. |
Hello,
Boost version: 1.74
Beast Version: 300
I've developed WebSocket server based on Beast which accepts a lot of messages of small size. The program needs quite a lot of CPU resources to work, perf shows it's mostly those functions:
boost::asio::execution::detail::any_executor_base::copy_object<boost::asio::io_context::basic_executor_type<std::allocator, 4u> >
boost::asio::execution::detail::any_executor_base::destroy_object<boost::asio::io_context::basic_executor_type<std::allocator, 4u> >
Server has about 250 open connections, accepting about 20 messages/second per connection. Message size between 100-5000 bytes.
Is it indended behavior?
The text was updated successfully, but these errors were encountered: