* Measuring startup-time from userspace
@ 2011-01-02 22:40 Taras Glek
2011-01-03 1:29 ` Ben Gamari
2011-01-03 5:12 ` Alexander Clouter
0 siblings, 2 replies; 3+ messages in thread
From: Taras Glek @ 2011-01-02 22:40 UTC (permalink / raw)
To: linux-kernel
Hi,
Does Linux provide a reasonable way to measure how long a process has
existed for? The goal is to have a function that returns the number of
milliseconds since process-creation.
We'd like to be able to have Firefox self-diagnose startup times.
Unfortunately, it turns out that library loading time adds a lot to
startup before application code runs, so a in-application timer would
underestimate startup time.
It appears that the most precise solution is to read start time from
/proc/self/stat. Unfortunately the time is in jiffies-since-startup and
there don't seem to be any good counters to compare against (ie
/proc/uptime doesn't provide enough resolution). So far the only
workable solution seems to create a new thread/process. Then one can do
(/proc/<newpid>/stat.starttime - /proc/self/stat.starttime) * 1000 / HZ
.
The question is, there way for a process to measure time-since-startup
without horrible hacks like spawning a new processes?
Taras
ps. Perhaps /proc/timer_list contains enough info?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Measuring startup-time from userspace
2011-01-02 22:40 Measuring startup-time from userspace Taras Glek
@ 2011-01-03 1:29 ` Ben Gamari
2011-01-03 5:12 ` Alexander Clouter
1 sibling, 0 replies; 3+ messages in thread
From: Ben Gamari @ 2011-01-03 1:29 UTC (permalink / raw)
To: Taras Glek, linux-kernel
On Sun, 02 Jan 2011 14:40:48 -0800, Taras Glek <tglek@mozilla.com> wrote:
> The question is, there way for a process to measure time-since-startup
> without horrible hacks like spawning a new processes?
>
Would you consider an LD_PRELOAD library to fall into the "hack"
category? I'm not sure when .init section is executed, but it might be
substantially earlier than when _start() is called.
- Ben
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Measuring startup-time from userspace
2011-01-02 22:40 Measuring startup-time from userspace Taras Glek
2011-01-03 1:29 ` Ben Gamari
@ 2011-01-03 5:12 ` Alexander Clouter
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Clouter @ 2011-01-03 5:12 UTC (permalink / raw)
To: linux-kernel
Taras Glek <tglek@mozilla.com> wrote:
>
> Does Linux provide a reasonable way to measure how long a process has
> existed for? The goal is to have a function that returns the number of
> milliseconds since process-creation.
>
At a glance:
----
alex@berk:~$ stat /proc/16863/
File: `/proc/16863/'
Size: 0 Blocks: 0 IO Block: 1024 directory
Device: 3h/3d Inode: 837808 Links: 6
Access: (0555/dr-xr-xr-x) Uid: ( 1000/ alex) Gid: ( 1000/ alex)
Access: 2011-01-03 05:07:47.888363341 +0000
Modify: 2011-01-03 05:07:47.888363341 +0000
Change: 2011-01-03 05:07:47.888363341 +0000
----
A nanosecond resolution timestamp for the moment when the pid is created
it seems. I could be completely wrong, but this seems to be one of
those "too easy to be true" moments.
Cheers
--
Alexander Clouter
.sigmonster says: Marriage is the sole cause of divorce.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-03 5:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-02 22:40 Measuring startup-time from userspace Taras Glek
2011-01-03 1:29 ` Ben Gamari
2011-01-03 5:12 ` Alexander Clouter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox