Re: [PATCH 1/4] Add clock_gettime_ns syscall

From: Arun Sharma
Date: Wed Dec 28 2011 - 17:45:52 EST

On Wed, Dec 28, 2011 at 12:13:37PM -0800, Andy Lutomirski wrote:
> > How about returning a (signed) long as the time in ns? This way, we save
> a store and a load and the value can be passed in registers.
> >
> > This shouldn't preclude future expansion via extra args.
> With an unconditional store to a pointer? If a null pointer is allowed,
> the branch will probably kill any performance gain.

No - please see the patch below.

> The downside is that this is probably a non-starter for a syscall on 32-bit
> architectures. I'll see what the i386 ABI says. I wonder if returning a
> struct will use registers for future expansion.

I was thinking of doing something similar to lseek() on 32 bit archs
(i.e. by using a type similar to off_t that maps to the right thing for
both 32 and 64 bit).

I used the code below to benchmark the performance of clock_gettime()
vs clock_gettime_ns() when the client is interested in a nanosec based

gettimespec: 3.19 secs
getns: 2.54 secs (21% faster)


PS: I didn't have to delete struct timens. I meant to drop timens.ns
(since its the return value now).