Question

I'm having a latency issue with select(). Actually I'm not sure if this is a problem with select() or not.

Story is like below.

  1. I'm using select() to detect a socket fd event.
  2. After select() wakes up, I do recv() to get data stream from a socket buffer.
  3. No problem with this and it works very well.

but...there is a latency problem... I have NIC tcpdump timestamp, Application's select() wakes up timestamp. These timestamps have big difference, over "15us".

No big logic in my application, just do select() socket fd and get timestamp with gettimeofday() function right after select() wakes up. I have no idea, why it takes that long to wake select() up.

I tested to make sure if select() is the problem or not. 1. No Select, Just loop to recv() socket fd until I get first data. 2. NIC gets a data stream, and I get tcpdump timestmap 3. recv() gets first data stream. 4. I get timestamp right after first recv() success.

This test shows big difference between NIC timestamp and recv() first timestamp.

Summary... After NIC gets data stream. 1. select() detects socket fd, it takes over 15us I think. 2. NO select() detects socket fd, only recv() loop until first data I get, it takes over 15us too.

Please somebody help me...Is this acceptable number? ( I mean over 15us. ) Or there is an check point I don't know ??

The Server HP, OS redhat 6.2 kernel 2.6

Was it helpful?

Solution

This is the scheduling delay in a general-purpose OS. Your only alternative is probably to switch to a real-time OS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top