[Bug libstdc++/13823] Significant performance issue with std::map on multiple threads on dual processor - possibly default allocator
ljrittle at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Jan 23 03:58:00 GMT 2004
------- Additional Comments From ljrittle at gcc dot gnu dot org 2004-01-23 03:58 -------
Try this (we might change the default allocator to make it work better for MP
at the next major library revision --- ABI change, but 3.4 will support this
allocator
with very good performance for people that wish to tune their application):
#include <iostream>
#include <map>
#include <ext/mt_allocator.h>
void *calc(void *n)
{
std::map<int, int, std::less<const int>,
__gnu_cxx::__mt_alloc< std::pair<const int, int> > > m;
for (unsigned i = 0; i < 100000; ++i)
m[i] = i;
return 0;
}
int main(int argc, char *argv[])
{
int n = argc == 2 ? std::max(atoi(argv[1]), 1) : 2;
pthread_t id[n];
for (int i = 0; i < n; ++i)
pthread_create(&id[i], 0, calc, new int(i));
for (int i = 0; i < n; ++i)
pthread_join(id[i], 0);
return 0;
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13823
More information about the Gcc-bugs
mailing list