public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, Bruno Haible <bruno@clisp.org>
Subject: Re: [PATCH] time: Use CLOCK_REALTIME for time (BZ #30200)
Date: Tue, 7 Mar 2023 08:45:05 -0300	[thread overview]
Message-ID: <32a9fa9c-2714-9e18-a3e7-bcfc2d61cd87@linaro.org> (raw)
In-Reply-To: <87ttywq0je.fsf@oldenburg.str.redhat.com>



On 07/03/23 08:11, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> Different than gettimeofday and timespec_get, time uses
>> CLOCK_REALTIME_COARSE instead of CLOCK_REALTIME on Linux.  The
>> coarse time is used mostly as optimization, but it may show
>> divergence progression due the clock resolution.
>>
>> For x86_64 and powerpc64, it should add slight more latency since
>> it would call now clock_gettime internally.
> 
> It seems really significant on x86-64.
> 
> Before:
> 
> min:        14 ns
> 25%:        16 ns
> 50%:        17 ns
> 75%:        17 ns
> 95%:        18 ns
> 99%:        18 ns
> max:     18722 ns
> avg:   16.6606 ns
> 
> After:
> 
> min:        29 ns
> 25%:        31 ns
> 50%:        31 ns
> 75%:        32 ns
> 95%:        32 ns
> 99%:        33 ns
> max:     12161 ns
> avg:   31.2205 ns
> 
> And of those original 17 ns, quite a bit is overhead from the
> benchmarking loop.  I guess applications could work around it by having
> a background timer thread that increments a global variable and use that
> instead of the time function call, but that seems not a great approach.

Yes, this is expected since time call will be route through clock_gettime.
Another fix would be to convince kernels developers to use CLOCK_REALTIME
on vDSO as well.

> 
> Based on previous feedback, I expect we'd have to carry a downstream
> revert of this patch indefinitely, so I'm rather strongly against
> applying it upstrean.

To me it really seems like a over-optimization specially because 'time'
has only second resolution.

  reply	other threads:[~2023-03-07 11:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 16:03 Adhemerval Zanella
2023-03-07 11:11 ` Florian Weimer
2023-03-07 11:45   ` Adhemerval Zanella Netto [this message]
2023-03-07 11:51     ` Florian Weimer
2023-03-07 11:57       ` Adhemerval Zanella Netto
2023-03-07 12:07         ` Florian Weimer
2023-03-08  5:51           ` Paul Eggert
2023-03-08  8:59             ` Florian Weimer
2023-03-08 23:08               ` Paul Eggert
2023-03-08 16:23             ` Bruno Haible
2023-03-08 16:57               ` Adhemerval Zanella Netto
2023-03-08 17:09                 ` Florian Weimer
2023-03-08 17:46                   ` Adhemerval Zanella Netto
2023-03-08 17:44                 ` Bruno Haible
2023-03-08 17:50                   ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32a9fa9c-2714-9e18-a3e7-bcfc2d61cd87@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=bruno@clisp.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).