Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analysis reports for STL implementation comparison (libstdc++, libc++, MS STL) #877

Open
honggyukim opened this issue Sep 17, 2019 · 6 comments

Comments

@honggyukim
Copy link
Collaborator

honggyukim commented Sep 17, 2019

Very recently, microsoft has open-sourced MSVC STL implementation on github.

It seems that it can be meaningful to compare the STL implementation for each library.

uftrace can be a useful tool for their analysis.

@namhyung
Copy link
Owner

Looks like an interesting topic for study.

@lacrimak3
Copy link
Contributor

I want to compare the STL implementation of each library

@honggyukim
Copy link
Collaborator Author

@sungho-yoon Thanks! We first have to make sure that if it's possible to build MS STL in Linux environment. Could you please try it first?

@lacrimak3
Copy link
Contributor

@honggyukim OK I'll try it first

@lacrimak3
Copy link
Contributor

lacrimak3 commented Sep 26, 2019

@honggyukim I need some help to analyze stl.
Maybe there is a problem tracing libc++ built-in functions.

Source code

#include <iostream>
using namespace std;

void algorithm_sort(){
    vector<int> a = {5, 4, 3, 2, 1};
    sort(a.begin(), a.end());
}

int main(void){
    algorithm_sort();
    return 0;
}

With g++, libstdc++
Compile option
g++ -pg a.cpp

Compile option
uftrace -t 1us a.out

Result(std::sort())

std::sort() {
            [  3096] |       std::__sort() {
            [  3096] |         std::__final_insertion_sort() {
            [  3096] |           std::__insertion_sort() {
            [  3096] |             std::move_backward() {
   1.300 us [  3096] |               std::__copy_move_backward_a2();
   1.700 us [  3096] |             } /* std::move_backward */
            [  3096] |             std::move_backward() {
   1.100 us [  3096] |               std::__copy_move_backward_a2();
   1.400 us [  3096] |             } /* std::move_backward */
   1.400 us [  3096] |             std::move_backward();
   1.300 us [  3096] |             std::move_backward();
  11.899 us [  3096] |           } /* std::__insertion_sort */
  12.299 us [  3096] |         } /* std::__final_insertion_sort */
  13.599 us [  3096] |       } /* std::__sort */
  13.899 us [  3096] |     } /* 

With clang++, libc++
Compile option
clang++ -pg -stdlib=libc++ a.cpp

Result
uftrace -t 1us a.out

# DURATION     TID     FUNCTION
            [  2978] | main() {
            [  2978] |   algorithm_sort() {
            [  2978] |     std::__1::vector::allocate() {
   1.900 us [  2978] |       operator new();
   5.200 us [  2978] |     } /* std::__1::vector::allocate */
   1.500 us [  2978] |     std::__1::__sort();
   8.700 us [  2978] |   } /* algorithm_sort */
   9.400 us [  2978] | } /* main */

I don't know how to trace libc++ built-in functions. Is there a way to trace it? With Full Dynamic Tracing, the results are same.
Should I rebuild libc++ with -pg option?

@honggyukim
Copy link
Collaborator Author

Sorry for missing to reply this thread. The STL functions inside libstdc++ are mostly provided in its header files, but libc++ provides most of implementation inside the library itself.

So it might not be able to trace many functions inside libc++. The best way to trace it is to recompile libc++ as well. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants