[llvm-bugs] [Bug 32554] New: performance bug: libc++ std::isinf() with integer input is very slow vs libstdc++

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 6 13:47:17 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32554

            Bug ID: 32554
           Summary: performance bug: libc++ std::isinf() with integer
                    input is very slow vs libstdc++
           Product: new-bugs
           Version: 4.0
          Hardware: All
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sean at rogue-research.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18239
  --> https://bugs.llvm.org/attachment.cgi?id=18239&action=edit
repro case

(filing this for a colleague that doesn't have an account here.)

While writing a templated function for both floating point and integral types,
I noticed that std::isinf with integer input is slow. I reduced the code to the
attached benchmark and ran it on macOS 10.11 and Fedora 25 with both clang and
GCC. With clang and libc++, using tag dispatch to first check if the type has
infinity speeds up the calculation by several times. With either compiler and
libstdc++, timings in both cases are fast and nearly identical.

It seems there is a performance bug in libc++'s std::isinf().


macOS 10.11 w/ clang 4.0.0 from homebrew
$ /usr/local/opt/llvm/bin/clang++ -O3 -std=c++1z isinf_libcxx.cpp
$ ./a.out
Using Detail::isinf
Time (s): 0.184412
Standard Deviation: 0.0100509
Using std::isinf
Time (s): 0.579823
Standard Deviation: 0.0205093

macOS 10.11 w/ gcc 6.3.0 from homebrew
$ g++-6 -O3 -std=c++1z isinf_libcxx?.cpp
$ ./a.out
Using Detail::isinf
Time (s): 0.195277
Standard Deviation: 0.016476
Using std::isinf
Time (s): 0.196114
Standard Deviation: 0.0161064

Fedora 25 w/ clang 3.9.1
$ clang++ -O3 -std=c++1z -stdlib=libc++ isinf_libcxx.cpp
$ ./a.out
Using Detail::isinf
Time (s): 0.161073
Standard Deviation: 0.00445347
Using std::isinf
Time (s): 1.40411
Standard Deviation: 0.089235

Fedora 25 w/ clang 3.9.1
$ clang++ -O3 -std=c++1z -stdlib=libstdc++ isinf_libcxx.cpp
$ ./a.out
Using Detail::isinf
Time (s): 0.162251
Standard Deviation: 0.00350547
Using std::isinf
Time (s): 0.160011
Standard Deviation: 0.00220987

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170406/8150cf2c/attachment.html>


More information about the llvm-bugs mailing list