c - epoll and send lag -


i'm using linux 64 bit linux scv 3.2.0-39-generic #62-ubuntu smp thu feb 28 00:28:53 utc 2013 x86_64 x86_64 x86_64 gnu/linux , have 2 processes using sockets run on same physical host.

one process (a) sends on tcp/ip socket (would local socket given host same) following pieces of data:

  1. 276 bytes
  2. 16 bytes

this done in 0.000023 seconds form process a. data being sent calling 2 times send socket api.

another process (b), receives data via epoll using epoll_wait(efd, events, 10, 5). data received follows (time taken clock_gettime(clock_realtime, &cur_ts);, matters relative difference):

  1. read data socket buffer @ 8051.177743 (276)
  2. call epoll 8051.177763 again
  3. read data socket buffer 8051.216250 (16)

making receiving process lag of 0.038507 seconds. if sending process a takes less ms, on receiving side epoll receive data adds additional lag of approximately 0.038 s.

is expected? doing wrong?
or how can improve situation?

thanks

is expected? ...

yes. expect that. here's why:

what doing wrong? ...

epoll designed used in situations large numbers of file descriptors need watched. that's it's suitable for, , seems me situation you're using isn't situation.

... how can improve situation?

if want improve performance, use right tool job. don't use epoll single socket. use plain-old vanilla recv. if you're handling 2 or 3 sockets, consider using poll or select. if you're venturing hundreds, might want consider using epoll or kqueue.


Comments

Popular posts from this blog

shader - OpenGL Shadow Map -

stringtemplate - StringTemplate4 if conditional with length -