megurikuru - 2011-02-14

While working on wirefilter to improve its performances, I found a more suitable function to retrieve a time reference. Actually wirefilter (and other components) is using gettimeofday(..) while i propose to use clock_gettime(..).
It has the same call time or only 5% slower where it's not implemented as VSYSCALL (it's nothing considering the whole contest, we say less than 1%).
clock_gettime is more suitable because of the nanosecond resolution and the monotonic behavior. Using it, the "counter" recently introduced isn't needed anymore because of the monotonic behavior.
gettimeofday() is useful where an "absolute" time reference is needed (I know absolute time references don't really exist but you know what I mean). In wirefilter a "relative" time reference is enough. clock_gettime(), practically, returns the "uptime" in seconds and nanoseconds. Also, keeping the time reference in nanoseconds instead of microseconds reduce the number of multiplications (while introduce the need for larger data types). Also, I'm thinking to use this to fine tune the timeout of vde_switch queue using ppoll instead of poll together with "dynamic" timeout change (see my other discussion for more info).
I have tested wirefilter and vde_switch with this call and it seems to be ok and the counter isn't used anymore for high bandwidth (it's always =0).
What do you think about it?