This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Performance issue with C++ STL

Hi.

For using STL with C++ in DSPs like TCI6618, are we expecting any performance degradation from without STL code?

If yes, can you please share some performcance data with and without STL c++ code execution, so that we can estimate the timing requirement correctly.

 

regards

Soumya

  • You should not experience any performance degradation due to using the STL features in the C++ RTS library.  We ran the Stepanov Benchmark with the C6000 compiler, and did not notice any degradation associated with using STL vectors and the like.  Note you must compile with optimization --opt_level=2 or higher to see such performance.

    Thanks and regards,

    -George

  • Well I ran this below code block for both STL vector and static array .

    The difference in 700usec in a loop of 1000 iteration. Even using O2 did not improve the timing.

    ----------------------------------------------------------------------------------------------------------

    typedef vector<RlcPduRecvBuffer *> RlcPduRecvBufferT;

    RlcPduRecvBufferT rlcPduRecvBufferList;

    //RlcPduRecvBuffer* rlcPduRecvBufferList[1000]; /** for Array **/

    for(int j = 0;j<5;j++)
    {
        Log_write1(UIABenchmark_start, (xdc_IArg)"process_sous_STL1");

        for(int i = 0;i<1000;i++)
        {
            RlcPduRecvBuffer *pRlcPduRecvBuffer = new RlcPduRecvBuffer();
           rlcPduRecvBufferList.push_back(pRlcPduRecvBuffer);
          //rlcPduRecvBufferList[i] = pRlcPduRecvBuffer; /** for Array **/
         delete rlcPduRecvBufferList[i];
        }

       Log_write1(UIABenchmark_stop, (xdc_IArg)"process_sous_STL1");

    }

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    Please let me know if i am missing something here as the understanding was with STL the performace wont degrade.

    700usec difference is a huge diff considering the time criticality our app has.

    regards

    Soumya

  • Hi,

    I suppose the overhead is due to the reallocatoin of the vector, triggered when you exaust the capacity.

    In this case, the push_back() enlarge the vector by a 50% and then, if required, copy the original vector to the new one and free the old one. Due to the "new" insisde the lopp and depending on the implementation of the freestore manager, the copy could accurs at every reallocation.

    Just to verify the performance, try to reserve the expected vector dimension (rlcPduRecvBufferList.reserve(1000*5)).

  • Well I can check that but that wont serve my purpose. Reserving static memory for vector is equivalent of a static array.

    So I guess the final word is overhead of STL will take more time compared to non-STL data structures

    But my understanding from first reply was STL with both use and overhead will not make any difference in time compared to other data structures in c++

     

    regards

    Soumya

     

  • It's not the same as a static array.  Even when you use "reserve", the array can still grow beyond that size.  Reserve is a performance optimization hint.