Epoll vs poll

Source: Internet
Author: User

Objective: To test whether epoll overhead is significantly lower than poll When epoll and poll are used at the same application layer.
Epoll uses the et Mode

Test method:
The server reads only data from the connected n clients. The system calls only poll and read, or epoll_wait and read, which is convenient for analysis. For the same number of poll and epoll_wait calls, the poll and epoll processes adopt the same read policy, that is, to read data in the FD when eagian occurs or the actual data read is less than the data in the read space. Both adopt non-congested Io

The client uses persistent connections to continuously send data and blocks data.

Test behavior:

The client uses 40 threads and continuously sends 100 bytes. You can see that the NIC is full.

Iptraf Detected

Poll flow: 95165 kbits/s

Epoll traffic: 97950 kbis/s

Poll:
System calls occupy the vast majority of the time and are rarely idle.
10:51:38 am CPU % USER % nice % System % idle intr/s
10:51:39 am all 2.00 0.00 78.00 20.00 12362.00
10:51:40 am all 2.00 0.00 75.00 23.00 12366.00
10:51:41 am all 4.00 0.00 74.00 22.00 12355.00
10:51:42 am all 0.00 0.00 83.00 17.00 12352.00
10:51:43 am all 2.00 0.00 77.00 21.00 12341.00
10:51:44 am all 4.00 0.00 80.00 16.00 12348.00
10:51:45 am all 2.00 0.00 78.00 20.00 12350.00
10:51:46 am all 1.00 0.00 82.00 17.00 12360.00
10:51:47 am all 2.00 0.00 80.00 18.00 12365.00
10:51:48 am all 4.00 0.00 82.00 14.00 12305.00
10:51:49 am all 3.00 0.00 82.00 15.00 12309.00
10:51:50 am all 2.00 0.00 81.00 17.00 12338.00
10:51:51 am all 5.00 0.00 77.00 18.00 12339.00
10:51:52 am all 2.00 0.00 80.00 18.00 12205.00
10:51:53 am all 3.00 0.00 71.00 26.00 12324.00
10:51:54 am all 2.00 0.00 74.00 24.00 12424.00
10:51:55 am all 1.00 0.00 79.00 20.00 12356.00
10:51:56 am all 3.00 0.00 78.00 19.00 12342.00
10:51:57 am all 5.00 0.00 74.00 21.00 12337.00
10:51:58 am all 2.00 0.00 79.00 19.00 12342.00
10:51:59 am all 2.00 0.00 79.00 19.00 12336.00
10:52:00 am all 6.00 0.00 70.00 24.00 12330.00
10:52:01 am all 6.00 0.00 74.00 20.00 12334.00
10:52:02 am all 3.00 0.00 74.00 23.00 12332.00
10:52:03 am all 2.00 0.00 77.00 21.00 12374.00
10:52:04 am all 3.00 0.00 77.00 20.00 12332.00
10:52:05 am all 0.00 0.00 78.00 22.00 12339.00
10:52:06 am all 0.00 0.00 80.00 20.00 12345.00
10:52:07 am all 5.00 0.00 75.00 20.00 12355.00
10:52:08 am all 3.00 0.00 77.00 20.00 12349.00
10:52:09 am all 1.00 0.00 81.00 18.00 12350.00
10:52:10 am all 3.00 0.00 76.00 21.00 12349.00
10:52:11 am all 8.00 0.00 74.00 18.00 12376.00

Epoll:

10:55:30 am CPU % USER % nice % System % idle intr/s
10:55:31 am all 2.00 0.00 23.00 75.00 12333.00
10:55:32 am all 3.00 0.00 23.00 74.00 12374.00
10:55:33 am all 3.00 0.00 24.00 73.00 12334.00
10:55:34 am all 1.00 0.00 24.00 75.00 12352.00
10:55:35 am all 5.00 0.00 21.00 74.00 12389.00
10:55:36 am all 2.00 0.00 24.00 74.00 12351.00
10:55:37 am all 2.00 0.00 25.00 73.00 12353.00
10:55:38 am all 2.00 0.00 24.00 74.00 12341.00
10:55:39 am all 2.00 0.00 24.00 74.00 12355.00
10:55:40 am all 4.00 0.00 26.00 70.00 12370.00
10:55:41 am all 2.00 0.00 24.00 74.00 12343.00
10:55:42 am all 2.00 0.00 30.00 68.00 12337.00
10:55:43 am all 0.00 0.00 26.00 74.00 12340.00
10:55:44 am all 1.00 0.00 25.00 74.00 12341.00
10:55:45 am all 0.00 0.00 26.00 74.00 12353.00
10:55:46 am all 1.00 0.00 18.00 81.00 12346.00
10:55:47 am all 1.00 0.00 27.00 72.00 12377.00
10:55:48 am all 1.00 0.00 24.00 75.00 12361.00
10:55:49 am all 1.00 0.00 27.00 72.00 12348.00
10:55:50 am all 1.00 0.00 25.00 74.00 12345.00
10:55:51 am all 1.00 0.00 30.00 69.00 12342.00
10:55:52 am all 1.00 0.00 29.00 70.00 12343.00
10:55:53 am all 2.00 0.00 23.00 75.00 12334.00
10:55:54 am all 2.00 0.00 23.00 75.00 12340.00
10:55:55 am all 2.00 0.00 21.00 77.00 12367.00
10:55:56 am all 1.00 0.00 27.00 72.00 12363.00
10:55:57 am all 1.00 0.00 23.00 76.00 12349.00
10:55:58 am all 2.00 0.00 21.00 77.00 12340.00
10:55:59 am all 1.00 0.00 22.00 77.00 12342.00
10:56:00 am all 1.00 0.00 27.00 72.00 12352.00
10:56:01 am all 2.00 0.00 24.00 74.00 12357.00
10:56:02 am all 1.00 0.00 28.00 71.00 12346.00
10:56:03 am all 3.00 0.00 24.00 73.00 12314.00

Top:

Poll:
22105 Loki 16 0 852 848 R 756 56.9 07 0 pollserver
21802 Loki 9 0 608 608 552 s 0.9 0: 00 0 mpstat

Epoll:
22108 Loki 14 0 904 900 r 808 9.9 0: 24 0 epollserver
22110 Loki 11 0 1168 1168 R 884 0.5 0: 00 0 top

Strac
Statistical results of poll system calls:
Strace-C./pollserver
Execve ("./pollserver", ["./pollserver"], [/* 28 vars */]) = 0
Servertest listen success!
% Time seconds usecs/call callerrors syscall
--------------------------------------------------------------
54.95 8.240026 74 111511 poll
45.03 6.751312 19 347887 read

 

Epoll System Call statistics:

% Time seconds usecs/call callerrors syscall
--------------------------------------------------------------
55.78 9.780626 30 323798 epoll_wait
44.20 7.749433 12 654077 read

The ratio of I/O multiplexing functions of poll and epoll is basically the same, and the traffic is the same, basically filling up the network card

But observe the results of top, and mpstat. Obviously, epoll's system call is better than poll's.

 

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.