public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* gettimeofday(), clock_gettime(), timer_gettime()
@ 2006-07-26  2:51 John Richard Moser
  2006-07-26 15:22 ` Andi Kleen
  2006-07-26 16:08 ` john stultz
  0 siblings, 2 replies; 4+ messages in thread
From: John Richard Moser @ 2006-07-26  2:51 UTC (permalink / raw)
  To: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm looking through a few things and noticing some complaints about time
and performance.  Briefly, the following things have come to my attention:

 - gettimeofday() is slow, or so they say, needing several milliseconds
to execute.

 - Apparently clock_gettime() exists, and can get the same information
as gettimeofday(); it gets its stuff in seconds and nanoseconds, which
is a little more precise than gettimeofday()

 - There are also timers that can count down time incrementally


So I have a few simple questions:

 - Is clock_gettime() faster than gettimeofday()? (doubt it)

 - If not, is timer_gettime() faster than gettimeofday() and clock_gettime()

If it turns out clock_gettime() is faster, then wow what the hell?
Otherwise I'm curious on timer_gettime() because it'll be pretty easy to
implement a timer-based clock tracker that adjusts for clock drift (yeah
if I keep timering and adjusting and resetting the timers the overhead
of maintaining the clock in userspace will drift me away from real
gettimeofday() values).

I'm planning out an interval timer based gettimeofday() in userspace as
an object oriented gettimeofday() mimicry; you'd have to pass a
structure to it for a created timer, because otherwise thread safety
would mean mutexes or thread local storage, both of which are slow.

- --
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.

    Creative brains are a valuable, limited resource. They shouldn't be
    wasted on re-inventing the wheel when there are so many fascinating
    new problems waiting out there.
                                                 -- Eric Steven Raymond

    We will enslave their women, eat their children and rape their
    cattle!
                  -- Bosc, Evil alien overlord from the fifth dimension
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBRMbYyws1xW0HCTEFAQIsbQ/9ED7UUxFygEUAzvCw0m+EoW7YSvlbkqkj
DDxinJnM/Q8CpcmpHgiMlRn/kHJUC/g44YwdKly/7QWwBTuLRB2Ys8WxdqrHaqdV
nAGz9SRtkWa09YLYFqc0n4E3zyn3NdVrB9/uP1NgeZRqwULALFX0zYz3CHZz5std
aZo1+XyHbeikxO7ECk0pNjghpzX7iUq1oGMaSNHptCSq4ASLRJqmCNdp+ozUilCi
FF/DrpSvKmhpuAsCRSkScqGyeY1qm06zDpMvTnrTuAnuX2GFDjRc9Z7d1JAFvxx1
1S1mWsu/vKz8gqvHsgXquuRuIZo9zNHdql2cHFJ0/nRBhJzldG9EvDVTQq684bq1
MCZ2p7Tpw4YV2cVcwxoESjluuhdsuiRc7OuAv6HdmeJ/ES+zQkyty0IBDpekTG9m
ZkBMaItDKwxn52AUeVH+em77a0e8K75IozpzEiLiHCoYpbGZvQIOxJl58TLs4X0P
mxbi8MCekIiikarRNhKh2CPn64OV6e4Iq1PVjrBUR4/rviszTQyaLL5F+jyFgWTb
CF5ovwjaU6E2FcW+vOakaLJogyoqGY6/hQOUuiN0J4cz6Bk8zRC5ZPL+zZ6/uMUp
Yo77rfHOhmMYzhAwENT17tvp6OQliC+GpxzCGLLHzbbI7wFOD0Kgl9zj29+KSi3c
IqtjC6+Q7e0=
=Bzic
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gettimeofday(), clock_gettime(), timer_gettime()
  2006-07-26  2:51 gettimeofday(), clock_gettime(), timer_gettime() John Richard Moser
@ 2006-07-26 15:22 ` Andi Kleen
  2006-07-26 16:15   ` John Richard Moser
  2006-07-26 16:08 ` john stultz
  1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2006-07-26 15:22 UTC (permalink / raw)
  To: John Richard Moser; +Cc: linux-kernel

John Richard Moser <nigelenki@comcast.net> writes:

>  - gettimeofday() is slow, or so they say, needing several milliseconds
> to execute.

It's not generally true, only sometimes. Please don't spread FUD.

-Andi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gettimeofday(), clock_gettime(), timer_gettime()
  2006-07-26  2:51 gettimeofday(), clock_gettime(), timer_gettime() John Richard Moser
  2006-07-26 15:22 ` Andi Kleen
@ 2006-07-26 16:08 ` john stultz
  1 sibling, 0 replies; 4+ messages in thread
From: john stultz @ 2006-07-26 16:08 UTC (permalink / raw)
  To: John Richard Moser; +Cc: linux-kernel

On 7/25/06, John Richard Moser <nigelenki@comcast.net> wrote:
> I'm looking through a few things and noticing some complaints about time
> and performance.  Briefly, the following things have come to my attention:
>
>  - gettimeofday() is slow, or so they say, needing several milliseconds
> to execute.

No. At worse its several microseconds (PIT takes about 18us, and its terrible!).
More likely you'll see ~1us using ACPI PM or HPET or ~500-100ns
(depending on your system).  With vsyscall it can get into the sub
100ns range.

thanks
-john

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gettimeofday(), clock_gettime(), timer_gettime()
  2006-07-26 15:22 ` Andi Kleen
@ 2006-07-26 16:15   ` John Richard Moser
  0 siblings, 0 replies; 4+ messages in thread
From: John Richard Moser @ 2006-07-26 16:15 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Andi Kleen wrote:
> John Richard Moser <nigelenki@comcast.net> writes:
> 
>>  - gettimeofday() is slow, or so they say, needing several milliseconds
>> to execute.
> 
> It's not generally true, only sometimes. Please don't spread FUD.
> 

http://lwn.net/Articles/192214/

"X is a big offender, apparently because the gettimeofday() call is
still too slow and maintaining time stamps with interval timers is faster."

Or so they say.  I'm not the one spreading FUD; amusingly it takes me
50uS to run gettimeofday().

> -Andi
> 

- --
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.

    Creative brains are a valuable, limited resource. They shouldn't be
    wasted on re-inventing the wheel when there are so many fascinating
    new problems waiting out there.
                                                 -- Eric Steven Raymond

    We will enslave their women, eat their children and rape their
    cattle!
                  -- Bosc, Evil alien overlord from the fifth dimension
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBRMeVNQs1xW0HCTEFAQImUg//eHXZfdTjazbLZFFUFVSoaCafunFzZyB5
uVmEq7yDWwsWe2jWTj9g3L/CpTECaiIAbcErrOxo8tGjN9PvGjKhfBTO8QmQAw6P
/InXa/DlPYN+ZhHAhXaNiS8CHMlVdSL6PT5NSMtugkepgRdQ4OhjOWe3MNgvSfdJ
tmUdq/clqz7S1gnPg8UvGOjgtUAlh+1+/7F/mYHgJn84DnexC81apVhP99jqvQ3o
u4dVyqxbfPIGkPDkZuorKY8HKeVLD6qettK8fK01pz2wgwSrjl1q+rZm2BGzuyMw
AAFtgfL/Z1DlEroaNcjAPJI3C43D4idGxpmtut/+sDP7wqxZ5LafULzotQWNbwDl
zi0MAfMbPkigPE8eUaQigHWTM7omvGFdadJhwx6Xd3ZmP2KTs6pCVU0X/A6i4ae/
fO1VbSztcVtoSy3Bz2jRIp4TjW1xuucdchjsT5yskpdEeeMwToKRV0qBTu1tyCv9
INQ4ovWNDsPgVLFx4l8EpcVlnYGelaJLNpzt+7bEFLsrW/q3thzCHFr440Cc5h4G
7Ukvu5s/a4BbMa6vnVPbaek7S8tBCrcHixzttJcjiObnxicZxr2V81sviVDMlCmy
zMuPeASzurgo2n3tDAmIwxICMUmsYB8l4oce7f1LLK9PFeOrVBhcLJymPCh8on4z
HIreAI1tj+Q=
=i75z
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-26 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-26  2:51 gettimeofday(), clock_gettime(), timer_gettime() John Richard Moser
2006-07-26 15:22 ` Andi Kleen
2006-07-26 16:15   ` John Richard Moser
2006-07-26 16:08 ` john stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox