This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Performance of the default Node Allocator.


Hi Dhruv,

very interesting! Am I missing something, I tried to compile your
testcase (in order to make a comp test with mt alloc of course ;) but
with little luck:

void:~/nstl$ /home/admin/gcc/bin/g++ balloc_test.cpp -I ./ -O3
In file included from ./nstl/algorithm.hpp:29,
                from nstl/balloc.hpp:35,
                from balloc_test.cpp:1:
./nstl/detail/nstl_algorithm.hpp: In member function `c
nstd::_quick_sort<t>::_aux_unstable_partition(c, c)':
./nstl/detail/nstl_algorithm.hpp:227: error: expected `;' before "__pivot"
./nstl/detail/nstl_algorithm.hpp:231: error: `__pivot' undeclared (first
use this function)
./nstl/detail/nstl_algorithm.hpp:231: error: (Each undeclared identifier
is reported only once for each function it appears in.)

The line in question is:
std::iterator_traits<c>::value_type __pivot = (*__first+*__last)/2;

The above was tried on:
void:~/nstl$ /home/admin/gcc/bin/g++ -v
Reading specs from /home/admin/gcc/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4-20040107/configure --prefix=/home/admin/gcc
--enable-threads --enable-languages=c,c++
Thread model: posix
gcc version 3.4.0 20040107 (experimental)

Brgds

/Stefan

Dhruv Matani wrote:

I was talking about the performance of the default node allocator in
situations where the list is sorted, and the nodes get splayed about in
memory, and then subsequent allocations/deallocations suffer due to bad
cache performance. I have here a bitmapped allocator that attempts to
remove those defects. I'm attaching a driver program that shows the
performance of the default node allocator v/s the bitmapped allocator.
You can see clearly that the bitmapped allocator not only allocates
memory faster, but also does not mess up the cache. If anyone wants the
source, I can send it by email. You can see that the sort is twice as
fast in the bitmapped allocator compared to the default node allocator
when used repeatedly. Also, could anyone test out these things for me on
other platforms?

Link to get the bitmapped allocator:
http://www.geocities.com/dhruvbird/nstl/nstl0.2.zip




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

#include <nstl/balloc.hpp>
#include <nstl/node_alloc.hpp>
#include <list>
#include <nstl/timer.hpp>
#include <cstdlib>
#include <iostream>

using namespace std;

using nstd::bitmap_allocator;


int main () { nstd::timer t;

typedef std::list<int, bitmap_allocator<int> > My_List;

//bitmap_allocator<int> ba;


// typedef std::list<int> My_List;


 //std::list<int, nstd::node_allocator<int> > il1;
 //  nstd::node_allocator<int> ba;

My_List il1;

 int ctr = 3;
 while (ctr--)
   {

t.start ();

 for (int i = 0; i < 550000; ++i)
   il1.push_back (rand()%10001);
   //    ba.allocate (1);
 t.stop ();

cout<<"Time Taken to Insert: "<<t.difference()<<" Seconds."<<endl;

My_List::iterator i = il1.begin();

cout<<"Size is: "<<il1.size ()<<endl;

 t.start ();
 il1.sort ();
 t.stop ();

cout<<"Time Taken to Sort: "<<t.difference()<<" Seconds."<<endl;

 //  il1.clear ();
 il1.erase (i, il1.end());

 cout<<"Size is: "<<il1.size ()<<endl<<endl;
   }


il1.clear (); int x; cin>>x;


}










Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]