C++Now 2017 has ended
Saturday, May 20 • 10:45am - 11:30am
Performance analysis and optimization of C++ standard libraries

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
Slides: https://github.com/boostcon/cppnow_presentations_2017/blob/master/05-20-2017_saturday/performance_analysis_and_optimization_of_cpp_standard_libraries__aditya_kumar_and_sebastian_pop__cppnow_05-20-2017.pdf
Video: https://www.youtube.com/watch?v=OTCp_AkAyRQ

We will present the performance analysis work on libcxx and libstdc++ and the changes we did to the libraries and to the LLVM compiler to optimize the code using the C++ standard libraries. This includes the improvements on standard library algorithms like string::find, libc++::basic_streambuf::xsgetn, libc++::stringstream. These algorithms were suboptimal and we improved those algorithms, particularly std::string which improved by more than 10x as a result of our work. Similarly, we enabled the inlining of constructor and destructor of libc++::std::string. We will present a systematic analysis of function attributes in libc++ and the places where we added missing attributes. We will present comparative analysis of libc++ vs. libstdc++ on commonly used algorithms, and show cases where std::sort of libstdc++ performs much better than that of libc++.

We will talk about std-benchmark (https://github.com/hiraditya/std-benchmark) that we started developing to help analyze performance across standard C++ libraries.

We will discuss the performance issues we are currently working on:
- Suboptimal parsing of numbers in libc++::stringstream
- Suboptimal libc++::std::sort
- Range checked access, for vectors (vector::at), is not properly optimized by the compiler
- Missing function attributes like __attribute__(noreturn)

For each of the performance issues that we have found, we will suggest possible solutions we are working on like improving the implementation or improved compiler optimizations (inlining extern templates, loop idiom recognition, loop rotation etc.)

If time permits, we will also present the lessons learnt as a result of analyzing C++ standard libraries like things to look out for while using standard C++ libraries, for example:
- Instead of std::rotate for std::list we can just exchange few pointers.
- Issue with the destructor of std::string
- Performance issues while using most commonly used containers such as std::vector, std::string

avatar for Aditya Kumar

Aditya Kumar

Software Engineer, Google
I've been working on LLVM since 2012. I've contributed to modern compiler optimizations like GVNHoist, Hot Cold Splitting, Hexagon specific optimizations, clang static analyzer, libcxx, libstdc++, and graphite framework of gcc.
avatar for Sebastian Pop

Sebastian Pop

Samsung Austin R&D Center
Loop optimizations, testing, benchmarks, performance tracking.

Saturday May 20, 2017 10:45am - 11:30am MDT
Flug Auditorium