Performance gain by avoiding arguments check is very small (less then 1%).
Amit
amitchoudhary0523@gmail.com
Tue Sep 30 01:54:33 GMT 2025
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.
------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250930/5c1a79e3/attachment.htm>
More information about the Libc-alpha
mailing list