Boost C++ Libraries: Ticket #9637: Boost.Container vector::resize() performance issue https://svn.boost.org/trac10/ticket/9637 <p> Hi, </p> <p> I noticed that resize() on a boost vector is quite slow compared to the equivalent operation on a std::vector: </p> <pre class="wiki">int size=2000000; std::vector&lt;char, std::allocator&lt;char&gt; &gt; vec; vec.resize(size); // ~500 us boost::container::vector&lt;char, std::allocator&lt;char&gt; &gt; vec2; vec2.resize(size); // ~3000 us </pre><p> I've attached a test program, compiled with "g++ -O3 -o test test.cpp" </p> <p> Environment: </p> <ul><li>gcc version 4.6.4 (<a class="missing wiki">Ubuntu/Linaro</a> 4.6.4-1ubuntu1~12.04) </li><li>boost 1.55.0 </li></ul><p> (Side note: the performance is even worse when compiled with -O0). </p> <p> cheers Dariush </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9637 Trac 1.4.3 Dariush Forouher <dariush@…> Thu, 06 Feb 2014 20:52:25 GMT attachment set https://svn.boost.org/trac10/ticket/9637 https://svn.boost.org/trac10/ticket/9637 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> Ticket Ion Gaztañaga Sat, 14 Jun 2014 14:08:32 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9637#comment:1 https://svn.boost.org/trac10/ticket/9637#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Thanks for the report. libstdc++ was using memset to initialize the array of chars. In commit (master and develop branches): </p> <p> SHA-1: 5afad7cd0c5512016f9ad60e03c95e84a470ce17 </p> <ul><li>Added optimization for types that can be value initialized with memset. </li></ul><p> Boost.Container uses memset with zero value to initialize several types including "char" values. </p> Ticket