| .NET DotNet Forum Index » Visual C++ Forum » Drastic slow-down in the execution time of my program... |
|
Page 1 of 1 |
|
| Author |
Message |
| Giovanni Dicanio... |
Posted: Thu Jun 25, 2009 8:58 am |
|
|
|
Guest
|
"Marcelo R" <MarceloR at (no spam) discussions.microsoft.com> ha scritto nel messaggio
news:E763D1D0-778A-4568-B0D3-29C6359E62F8 at (no spam) microsoft.com...
Quote: the compiler is Visual C++ 6.0.
[...]
I
wrote a test program that doesn't use the framegrabber at all and the
slowdown still happens.
[...]
Any ideas or suggestions of how to go about troubleshooting this thing?
In additon to Carl's detailed answer, I would like to suggest you to rebuild
your test code with a more modern compiler, like VS2005 or 2008.
You can find the Express Edition as freely available download.
I think that more modern C/C++ compilers can produce higher-quality binary
code.
Giovanni |
|
|
| Back to top |
|
|
|
| Marcelo R... |
Posted: Thu Jun 25, 2009 1:42 pm |
|
|
|
Guest
|
Thanks again. The test program is a single-thread console application. At
the beginning it opens a file and reads its contents into an array of 768 K
bytes. The file is closed and then the calculations are done on this array.
No extra memory is allocated.
I think you might be on to something with the cache idea. The computers have
only 512 MB of RAM. I added another 512 MB to one of them and it has been
running without slowing down for a few hours. Still early to say, but maybe
that's a solution.
The CPU is a Pentium 4 2.8GHz. I am not sure any of the other computers that
I tested has the same CPU. |
|
|
| Back to top |
|
|
|
| Marcelo R... |
Posted: Thu Jun 25, 2009 2:56 pm |
|
|
|
Guest
|
Grazie Giovanni. I did recompile with VS2005 and the only difference it made
is that the normal runs are now taking 16 seconds instead of 19 - so a good
performance improvement there - but the slow-down problem still happens
(seemingly) at random.
"Giovanni Dicanio" wrote:
Quote:
"Marcelo R" <MarceloR at (no spam) discussions.microsoft.com> ha scritto nel messaggio
news:E763D1D0-778A-4568-B0D3-29C6359E62F8 at (no spam) microsoft.com...
the compiler is Visual C++ 6.0.
[...]
I
wrote a test program that doesn't use the framegrabber at all and the
slowdown still happens.
[...]
Any ideas or suggestions of how to go about troubleshooting this thing?
In additon to Carl's detailed answer, I would like to suggest you to rebuild
your test code with a more modern compiler, like VS2005 or 2008.
You can find the Express Edition as freely available download.
I think that more modern C/C++ compilers can produce higher-quality binary
code.
Giovanni
|
|
|
| Back to top |
|
|
|
| Carl Daniel [VC++ MVP]... |
Posted: Thu Jun 25, 2009 8:14 pm |
|
|
|
Guest
|
Marcelo R wrote:
Quote: Thanks again. The test program is a single-thread console
application. At the beginning it opens a file and reads its contents
into an array of 768 K bytes. The file is closed and then the
calculations are done on this array. No extra memory is allocated.
I think you might be on to something with the cache idea. The
computers have only 512 MB of RAM. I added another 512 MB to one of
them and it has been running without slowing down for a few hours.
Still early to say, but maybe that's a solution.
Interesting. Rather than cache, I'd wonder if you're experiencing some kind
of virtual memory thrashing. Try using Perfmon to monitor the hard page
fault rate (Object: Memory, Counter: Page Reads/Sec). Adding memory is
unlikely to significantly affect cache alignment, but it can absolutely
affect virtual memory layout. For what you describe, 512MB sounds like it
ought to be plenty, but if adding RAM improved it, I'd be highly suspicious
of thrashing.
Quote:
The CPU is a Pentium 4 2.8GHz. I am not sure any of the other
computers that I tested has the same CPU.
Well, that's an ordinary enough CPU, so it doesn't sound like there's
anything to worry bout there.
-cd |
|
|
| Back to top |
|
|
|
| Marcelo R... |
Posted: Sun Jun 28, 2009 11:26 am |
|
|
|
Guest
|
Actually adding RAM seems to have reduced the frequency of the problem but
did not eliminate it.
I tried PerfMon and I didn't see a difference in the Page Reads/Sec count
during "normal" and "slow" runs. It was my first time using PerfMon, so I
might not have done it right.
Do you know of any other counter that PerfMon monitors that might give a
clue to what is going on?
Thanks again. |
|
|
| Back to top |
|
|
|
| Ben Voigt [C++ MVP]... |
Posted: Fri Jul 03, 2009 8:08 am |
|
|
|
Guest
|
"Marcelo R" <MarceloR at (no spam) discussions.microsoft.com> wrote in message
news:FC3E03A3-0EB0-481E-9388-30510B0CAF71 at (no spam) microsoft.com...
Quote: Actually adding RAM seems to have reduced the frequency of the problem but
did not eliminate it.
I tried PerfMon and I didn't see a difference in the Page Reads/Sec count
during "normal" and "slow" runs. It was my first time using PerfMon, so I
might not have done it right.
Do you know of any other counter that PerfMon monitors that might give a
clue to what is going on?
I would suggest using an IP sampling profiler that collects call stacks.
That'll find out what part of your code is getting stuck.
Quote:
Thanks again.
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4212 (20090703) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4212 (20090703) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com |
|
|
| Back to top |
|
|
|
| SvenC... |
Posted: Fri Jul 03, 2009 3:04 pm |
|
|
|
Guest
|
Hi Marcelo,
Quote: Actually adding RAM seems to have reduced the frequency of the problem but
did not eliminate it.
I tried PerfMon and I didn't see a difference in the Page Reads/Sec count
during "normal" and "slow" runs. It was my first time using PerfMon, so I
might not have done it right.
Do you know of any other counter that PerfMon monitors that might give a
clue to what is going on?
For a quick look you can also take Task Manager (press ctrl+shift+esc) and
click on the processes tab. What happens to the memory column, does the
value increase for every run? You migh use View->Select columns to add
the column for virtual memory and look as that as well.
It those values only go up and never down, than you do have a memory
leak. Check your allocation and deallocation calls.
--
SvenC |
|
|
| Back to top |
|
|
|
|