Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2007

Tip: Looking for answers? Try searching our database.

Variable execution speed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark S - 03 Oct 2007 13:26 GMT
I have an application that consists of a managed C++ wrapper around an
unmanaged C++ "engine" that performs a very processor intensive task.   In
the application I create two instances of the managed wrapper (and therefore
of the unmanaged engine) on separate threads so that it can be working on two
scenarios at the same time.  The engine keeps track of certain counters so
that I can monitor it's progress.

However, I'm finding that the engine executes at different speeds on
different occasions when I run the application with exactly the same
scenarios.  In fact, sometimes one instance of the engine runs at the speed
I'm expecting and the other runs at about one tenth of the normal speed, even
though they are instances of exactly the same code, running on a dual core
processor with nothing else running at the same time.

I find myself running the application, checking the speed, and, if it's not
running at the normal speed I shut it down, start it again, check the speed,
etc, until, for no apparent reason, it starts up running at full speed.  It's
the only way I can find to get the application working at full potential on
both threads and it's very annoying!

Does anyone have any idea what might be causing this?  I'm still a C++
beginner so I'm hoping this can be fixed with a compiler option or two.

I'm using VC++ 2005 on a Pentium D and Win2K.

Thanks in advance.
Bruno van Dooren - 08 Oct 2007 09:40 GMT
> However, I'm finding that the engine executes at different speeds on
> different occasions when I run the application with exactly the same
[quoted text clipped - 9 lines]
>
> I'm using VC++ 2005 on a Pentium D and Win2K.

What are your threads doing? Are they working on the same data? Do they use
global data / file io/ synchronization mechanisms like mutexes, events or
critical sections?
There are a lot of things that influence the perfromance of parallel
programmed threads. We need some more info to help you.

Signature

Kind regards,
   Bruno van Dooren  MVP - VC++
   http://msmvps.com/blogs/vanDooren
   bruno_nos_pam_van_dooren@hotmail.com

Mark S - 08 Oct 2007 23:51 GMT
The threads are completely distinct.  They are created by (and the code that
they execute is in) different instances of the same class.  They do not share
any variables, memory or any other resources.  The objects are initialized
with a "scenario" and then are set running in order to "solve" it (which can
take seconds, minutes or even hours depending on the scenario).  The
processing consists entirely of processing in memory.

The latest thought I have is that the problem is not due to the threading at
all but rather due to caching on the CPU (though I really have no idea about
the mechanics of caching - it's a wild guess).  The scenarios allocate lots
of relatively small amounts of memory during initialization.  Perhaps these
bits of memory are being fragmented in some cases and are messing up the
caching so that there are lots of cache misses, slowing down the processing.  
I'm currently working on allocating all of the memory in one block to see if
that has any effect.

My only other thought is that it's just a "feature" of the CPU or Win2K.  
I've noticed Visual Studio being affected by something similar.  Sometimes it
will seem to be running really slowly.  For example, selecting multiple lines
of text by scrolling down (using the down arrow) while holding the shift key
down is very slow; compiling takes longer than usual.  Once I shut VS down
and start it up again everything happens at normal speed.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.