This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libstdc++/13823] Significant performance issue with std::map on multiple threads on dual processor - possibly default allocator


------- Additional Comments From devison at pacificit dot co dot nz  2004-01-23 03:58 -------
Subject: Re:  Significant performance issue with std::map
 on multiple threads on dual processor - possibly default allocator


thanks - I can see that's better being able to time it, and it simplifies
the program.

I'm no expert here, but perhaps it would still be best to have an outer loop
in the calc function - say 5 or 10 iterations.  That may exercise the
allocator a bit more, repeatedly allocating and deallocating from the pool.

As an aside - I didn't know an array could have a variable as its size.
Stroustrup's C++PLv3 says "The number of elements of the array, the array
bound, must be a constant expression".  But I see it compiles and works with
gcc!

(btw I was aware of the misuse :)


----- Original Message -----
From: "ljrittle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <devison@pacificit.co.nz>
Sent: Friday, January 23, 2004 4:38 PM
Subject: [Bug libstdc++/13823] Significant performance issue with std::map
on multiple threads on dual processor - possibly default allocator


>
> ------- Additional Comments From ljrittle at gcc dot gnu dot org
2004-01-23 03:38 -------
> FYI, the initially submitted case misused pthread_join (granted moot since
> threads never
> exit).  Here is a better version for our use (this one exits, thus easier
to time):
>
> #include <iostream>
> #include <map>
>
> void *calc(void *n)
> {
>   std::map<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;
> }
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13823
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
>




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13823


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