From: Markus Alber <markus@hyperion-imrt.org>
To: Michael Snyder <msnyder@vmware.com>
Cc: <gdb@sourceware.org>
Subject: Re: performance of multithreading gets gradually worse under gdb
Date: Thu, 03 Feb 2011 07:03:00 -0000 [thread overview]
Message-ID: <0e69c90ce85e34a24a5bcef1ce391aae@hyperion-imrt.org> (raw)
In-Reply-To: <4D49D016.7000607@vmware.com>
[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]
On Wed, 02 Feb 2011 13:43:50 -0800, Michael Snyder wrote:
>> It allocates about 100kB per iteration.
>
> Hmmm, and that's for roughly 36 thread start/stops, so it could be
> losing roughly 3000 bytes per thread. That's much bigger than my
> first guess would have been (a "struct thread_info" is only 336
> bytes).
>
>> One interesting finding might also be:
>> I terminated the process when an iteration took about 3 min (instead
>> of 1 sec)
>> and gdb had about 115MB allocated.
>
> I assume that at this point, your system still had plenty of ram to
> spare? It wasn't simply swapping?
The system had about 20 GB to spare.
>> On starting the application again, it ran alright for a while and
>> the gdb memory allocation
>> stayed constant. When it finally started to grow again, the
>> application slowed down, and became
>> slower with every iteration - the usual picture.
>> I attached a sample file from the application where the computation
>> bifurcates into
>> the worker threads. This is one of three instances per iteration,
>> but they all follow the
>> same pattern.
>
> I was really hoping for a stripped-down sample that we could compile
> and run.
See the attached file. It shows a similar behaviour, although it only
allocates 8kB per iteration.
You have to wait some time before this happens.
>> The machine has 2x6 cores x 3 instances per iteration = 36 worker
>> threads per iteration.
>
> x86 architecture?
>
>> On another note, I tried to compile gdb-6.5 on my machine (because
>> it was the release I
>> used to work with before, without problems) and configure comes
>> back with an error that it cannot find a termcap lib. There is none on
>> the SuSE. Which package would I need to install?
>
> That would be libncurses, I think.
I compiled gdb-6.5 alright and it performs well as usual, without this
problem.
>
>
>> On Wed, 02 Feb 2011 12:27:58 -0800, Michael Snyder wrote:
>>> Markus Alber wrote:
>>>> Hello,
>>>> I have experienced the following problem:
>>>> I'm debugging a number-crunching application which spawns a lot
>>>> (36) little
>>>> worker threads per iteration. The system does typically OoM 200
>>>> iterations.
>>>> Although each of them should take about the same amount of time,
>>>> the performance
>>>> gets worse with every iteration and becomes excruciatingly slow.
>>>> A system monitor reveals that gdb allocates more memory with every
>>>> iteration,
>>>> i.e. with every 36 threads started and finished. The CPU load of
>>>> GDB goes up, too.
>>>> The CPU usage of the application goes down. Compared to the solo
>>>> performance, it
>>>> gets slower by a factor 20 and more, if run long enough.
>>>> The application behaves perfectly when run by itself. The
>>>> multi-threaded part is not
>>>> debugging compiled when this behaviour occurs.
>>>> The distribution is SuSE 11.3 / gdb 7.1.
>>>> Is there anything I can change about this behaviour, any options
>>>> of gdb that need to
>>>> be set in these circumstances?
>>> Interesting.
>>>
>>> By how much does gdb's memory allocation increase?
>>> In total or, if possible, per iteration? This might
>>> give is a clue as to where to look.
>>>
>>> Do you think you could write a simple sample program that
>>> allocates threads in a manner similar to your application?
>>>
>>> Thanks,
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mt_test.cpp --]
[-- Type: text/x-c++src; name=mt_test.cpp, Size: 1555 bytes --]
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
using namespace std;
// Compile with: g++ -g -lboost_thread mt_test.cpp
struct ThreadData {
ThreadData(const vector<double>& vOne,
const double factor) :
m_vOne(vOne),
m_factor(factor),
m_vTwo(vOne.size(), m_factor)
{
// empty
}
const vector<double>& m_vOne;
double m_factor;
vector<double> m_vTwo;
};
static void* doAdd(void* data)
{
ThreadData* pData = static_cast<ThreadData*>(data);
for(unsigned int nAt = 0; nAt < pData->m_vOne.size(); ++nAt)
pData->m_vTwo[nAt] += pData->m_factor * pData->m_vOne[nAt];
return NULL;
}
int main(void) {
const int nThreads = 12;
const int nRepetitions = 200;
vector<double> vOne(1<<24, 1.0);
for(int nAtRepetition = 0; nAtRepetition < nRepetitions; ++nAtRepetition) {
cout << "Repetition no. " << nAtRepetition << endl;
vector<ThreadData*> vpData(nThreads, static_cast<ThreadData*>(NULL));
boost::thread_group threads;
for (int nAtThread = 0; nAtThread < nThreads; nAtThread++) {
vpData[nAtThread] = new ThreadData(vOne, static_cast<double>(nAtThread+1) );
if( threads.create_thread( boost::bind(&doAdd, static_cast<void*> (vpData[nAtThread])) ) == 0 )
throw std::exception();
}
threads.join_all();
for (int nAtThread = 0; nAtThread < nThreads; nAtThread++)
delete vpData[nAtThread];
}
return 0;
}
next prev parent reply other threads:[~2011-02-03 7:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-02 20:16 Markus Alber
2011-02-02 20:28 ` Michael Snyder
[not found] ` <76bccf1875854ebc69b6a892fb84a976@hyperion-imrt.org>
2011-02-02 21:43 ` Michael Snyder
2011-02-03 7:03 ` Markus Alber [this message]
2011-02-03 20:26 ` Michael Snyder
2011-02-03 20:52 ` Markus Alber
2011-02-03 20:57 ` Tom Tromey
2011-02-03 21:00 ` Tom Tromey
2011-02-03 21:40 ` Ulrich Weigand
2011-02-03 22:04 ` Tom Tromey
2011-02-04 13:49 ` Ulrich Weigand
2011-02-04 14:55 ` Pedro Alves
2011-02-04 15:13 ` Ulrich Weigand
2011-02-04 15:26 ` Tom Tromey
2011-02-04 15:56 ` Pedro Alves
[not found] ` <201102041555.52179.pedro__21913.9744448059$1296834976$gmane$org@codesourcery.com>
2011-02-04 17:02 ` Tom Tromey
2011-02-05 9:34 ` Markus Alber
2011-02-07 14:05 ` Markus Alber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e69c90ce85e34a24a5bcef1ce391aae@hyperion-imrt.org \
--to=markus@hyperion-imrt.org \
--cc=gdb@sourceware.org \
--cc=msnyder@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox