Coroutine Libraries: Network performance explosion ASIO asynchronous model (-O3 test)

Source: Internet
Author: User

There is a co-libraries in the GitHub organization of the Purecpp community: https://github.com/topcpporg/cpp_features

Recently there are users to find me, want to know about the Coroutine library in the network performance, so select the standard library has been selected Boost.asio network library asynchronous model to do a horizontal comparison.

In the case of small packets and the use of multicore, the network performance of the Coroutine library ASIO asynchronous model, 8 thread processing packet gap can reach more than 10 times times.

In the case of large package + single thread, the Coroutine library's network is not much higher than the ASIO async model, and even performance is present on some poor performance pc.

  PS: Prior to a comparison test, it was pointed out that the test did not open O3 optimization, ASIO extremely unfair

The blog that announced the results of the test has been deleted, hereby open O3 optimization re-test again, record straight.

Briefly describe the testing process:

1.TCP protocol, c/s is the same physical machine two processes, establish 1000 connections

2. The service is the Echo server, received the data is sent back, the client sends the packet of the specified size indefinitely, the test sample packet size is: 4 bytes, 32 bytes, 128 bytes, 1024 bytes, 4096 bytes

3. Test for different thread count, test sample threads: Single thread, 2 thread, 4 thread, 8 thread

4. The service-side programs used for contrast testing are:

A) written in Coroutine

B) written with Boost.asio asynchronous model

5. Use the same client program to reduce interference

5. The test environment is a physical machine server with 2 6 core 12 thread CPUs, a total of 24 logical threads, and the Linux system version is: CentOS 6.2.

(The core less PC can not play the Coroutine advantage, the test result gap will be reduced)

Test result diagram:

  

This test, and does not indicate that the performance of ASIO is certainly worse than the network performance of Coroutine Library, ASIO is a layer of system call package, very nice design, left the user a great margin of optimization;

It is also hoped to achieve or surpass the network performance of the Coroutine library by taking great pains to tune the ASIO.

In the actual use of the Coroutine library, I am more recommended is the use of the Coroutine+asio synchronization model, performance and development efficiency can be both, and not from the system call write!

The server used for this test is the Benchmark/co_server.cpp and Benchmark/asio/async_asio_server.cpp client code in the GIT library: benchmark/co_client.cpp

Example of using Coroutine+asio synchronization in the Benchmark/asio_sync directory

Community Exchange Group: 296561497

Coroutine Libraries: Network performance explosion ASIO asynchronous model (-O3 test)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.