IBM Support

LI76152: SLOWER RUNTIME PERFORMANCE WITH XLC VS. G++

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • A significant performance difference is observed when compiling
    the following test case with xlC vs. g++.
    
    ===== Test case:
    main.cpp:
      #include <iostream>
      #include <fstream>
    
    
      int main( int argc, char** argv )
      {
          int vueltas = 1;
    
          if ( argc == 2 )
              vueltas = atoi( argv[1] );
    
          while ( --vueltas >= 0 )
          {
              std::ifstream ifs( "File.txt" );
    
              if ( ifs.is_open() )
              {
                  while ( !ifs.eof() )
                  {
                      char buf[200];
                      ifs.getline( buf, sizeof( buf ) );
      //                std::cout << buf << std::endl;
                  }
    
                  ifs.close();
              }
          }
      }
    
    File.txt:
      Online file 1
      Online file 2
      Online file 3
      Online file 4
      Online file 5
      Online file 6
      Online file 7
      Online file 8
      Online file 9
      Online file 10
    
    =====================
    
    ===== Performance:
    The following performance numbers are observed when the text
    file 'File.txt' is opened, read and closed 2 million times.
    
    g++:
    real    0m14.463s
    user    0m4.771s
    sys     0m9.096s
    
    xlC:
    real    3m46.124s
    user    2m47.589s
    sys     0m30.686s
    

Local fix

  • Use the fstream.h and iostream.h headers, instead of the fstream
    and iostream header files.
    

Problem summary

  • PROBLEM DESCRIPTION:
    A performance hit is encountered due to the unnecessary
    creation of locale objects.
    
    USERS AFFECTED:
    Users who create lots of 'fstream' objects.
    

Problem conclusion

  • Make the duplicate locale objects the same.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76152

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2011-06-10

  • Closed date

    2011-06-10

  • Last modified date

    2011-06-10

  • APAR is sysrouted FROM one or more of the following:

    IZ91285

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI76152

Modified date: 10 June 2011