LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2022, 04:46 AM   #1
grom358
LQ Newbie
 
Registered: Aug 2022
Posts: 3

Rep: Reputation: 0
epoll echo server


Doing some basic benchmarks on linux epoll using https://github.com/frevib/epoll-echo-server

Code:
grom@grom-laptop:~/tmp/echo$ dd if=test.bin bs=4096 count=10240000 | ncat localhost 7777 > /dev/null
^C461+0 records in
460+0 records out
1884160 bytes (1.9 MB, 1.8 MiB) copied, 13.3298 s, 141 kB/s
If compare to io_uring implementation:

Code:
grom@grom-laptop:~/tmp/echo$ dd if=test.bin bs=4096 count=10240000 | ncat localhost 7777 > /dev/null
2560000+0 records in
2560000+0 records out
10485760000 bytes (10 GB, 9.8 GiB) copied, 10.3257 s, 1.0 GB/s
This test.bin is just a file with random bytes created from /dev/urandom

Clearly I'm doing something wrong. No way epoll is this slow. I looked at the epoll code and nothing stands out as wrong to me. Compared it with some other code examples.
 
Old 08-28-2022, 06:20 AM   #2
grom358
LQ Newbie
 
Registered: Aug 2022
Posts: 3

Original Poster
Rep: Reputation: 0
I went and tested using https://github.com/tokio-rs/tokio/tree/master/tokio which is using epoll under the hood:

Code:
grom@grom-laptop:~/tmp/echo$ dd if=test.bin bs=4096 count=10240000 | ncat localhost 7777 > /dev/null
2560000+0 records in
2560000+0 records out
10485760000 bytes (10 GB, 9.8 GiB) copied, 9.74089 s, 1.1 GB/s
So still confused what is so wrong with the C example.
 
Old 08-28-2022, 07:43 AM   #3
grom358
LQ Newbie
 
Registered: Aug 2022
Posts: 3

Original Poster
Rep: Reputation: 0
I come across https://github.com/millken/c-example...poll-example.c

The solution was to have a loop over calling read until EAGAIN


Which is in the man page:

Quote:
An application that employs the EPOLLET flag should use
nonblocking file descriptors to avoid having a blocking read or
write starve a task that is handling multiple file descriptors.
The suggested way to use epoll as an edge-triggered (EPOLLET)
interface is as follows:

a) with nonblocking file descriptors; and

b) by waiting for an event only after read(2) or write(2) return
EAGAIN.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fstat() on epoll fd returns a value in st_mode which indicates that it is a regular file. Is this file type correct for an epoll fd? Bikku Linux - Newbie 4 02-05-2020 06:59 AM
echo 0:$(echo 8*35*37*47 | bc) | xxd -r && echo $(id -un) Linuxanity LinuxQuestions.org Member Intro 1 08-15-2012 06:30 PM
EPOLL echo server not concurrent Lantzvillian Programming 5 02-19-2011 08:59 PM
epoll problem Parahat Melayev Programming 1 03-17-2005 05:22 AM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration