Performance gain by avoiding arguments check is very small (less then 1%).
Sam James
sam@gentoo.org
Tue Sep 30 15:18:48 GMT 2025
Amit <amitchoudhary0523@gmail.com> writes:
> On Tue, Sep 30, 2025, 2:23 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi Amit,
>
> Modern compilers will optimize your example code away. You can see that
> there are no checks at all in the main function: https://godbolt.org/z/aeeTx6zqM
>
> Even if it wasn't optimized, it wouldn't be possible to measure any difference.
> Running an empty main() in a loop will just measure shell overheads. Your
> results show it takes a few million cycles per iteration, so an extra check cannot
> be measured. What you're really measuring is the varying turbo frequency of
> your laptop...
>
> Benchmarking is hard, much harder than you think. It is done by creating a
> tight loop around any code you want to measure. You have to use inputs that
> are representative of real usage (ideally from traces from actual workloads).
> For timing we use a high-resolution (nano-second) timer. You can look at
> recent benchmarks in benchtests/ that show how it should be done.
>
> Cheers,
> Wilco
>
> I am not going to get into any discussion because I have learned that glibc people are defensive people and they will
> defend their wrongdoings.
I think Wilco's reply was respectful and professional. It's also
accurate. I don't see it as defensive at all.
>
> ------------
More information about the Libc-alpha
mailing list