Windows Under The Hood issue

This is a discussion on Windows Under The Hood issue within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I (or actually we) have a tricky performance issue with our simulator that was annoying a couple of years ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Windows Under The Hood issue

    Hi,
    I (or actually we) have a tricky performance issue with our simulator that was annoying a couple of years ago but has now become a real problem. The application does not hang, but it produces a ton of error printouts that does not exist in real life i.e. when the application runs in the target (not in PC).

    Background:
    The simulator consist of a couple of win32 console applications, written in C++. When the console applications starts up, they instantly creates a second window that have the GUI. We usually start at least four (4) different applications that communicates (IPC) with each other through a memory mapped file, where we use system calls like PulsEvent, Mutex and Semaphores. Furthermore - we are using MetaWINDOW from Metagraphics Software Corporation, mainly because its fast and can run in both Windows and on the target system with a RTOS. But once again, the performance problem is in the simulator i.e. PC with Windows.

    Problem description:
    The PC (Wintel) that runs our simulator must be connected to the Intra-net/Internet in order to work and perform properly. And here comes the funny part: It even performs better if we start up IE/FireFox and have a home page that contains... well we don't know actually, like www.times.com. So our application when running as a simulator in Wintel is addicted to be connected to Internet, have a browser with some specific home pages !!

    Our conclusion:
    We think that since we use some low level win-api commands (Mutex/Semaphores) in our applications and those are surely used by the browsers and in extent the network drivers, Windows itself boosts up the priority of some ActiveX component that is related to the browser functionality. And Voila !! our application is enjoying a free lunch and works fast and smooth! Is this strange/odd? I don't know, it's crazy but it's a fact.

    So my question is, does anybody recognize this phenomena and is there any solution to get rid of the dependency of the connection to Intra-net/Internet + browser + some home page? I am grateful of any suggestions what to to, what so ever!

    Thanks in advance

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sounds unlikely that Windows would use "dirty tricks" to "hack itself".

    It is more likely a side-effect of some other type - perhaps having a web-site loaded (particularly if it's got "active" content, e.g. moving graphics or some flash) causes the system to task-switch more often, causing your application to be more active, rather than running in a single task all the time.

    Try running a profiler (e.g. VTune or AMD CodeAnalyst) on the system with and without the browser open, and see if there is a difference somewhere.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    Thank you for the response matsp, I appreciate it !
    I will try to use VTune and see if I could get something out of it. Until today, I needer have used or heard about VTune, so I am a little bit impatient to get started and see if the program could locate our problem. Unfortunately, the program was not for free, but I can use it for 30 days, and that should be enough. I hope that this evaluation version is not stripped in any way. I forgot to mention that each task in our application is started in an own thread and it's not unusual that application have 50 tasks or more. So there will be a lot of threads to supervise - that's for sure !

    I disagree in one thing that you wrote though <<use "dirty tricks" to "hack itself". >> It's a very common thing in the RTOS world that some processes, or tasks, could temporary have their priority raised by the OS. Why? Because a low priority process could allocate e.g. a Mutex or a Semaphore and by that block a process with a higher priority that are also interested of the same resource. The solution is to boost up the priority of the low priority process and let it finish the job so the other processes with normally higher priority could get the CPU. So I don't think that's dirty tricks, it's actually a very common way to solve tricky situations.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sure, changin the priority of tasks is a valid thing (to prevent priority inversion). I doubt that will make your tasks run any faster tho'. I think it is something else.

    VTune trial is full-feature (or at least, it used to be some two-three years ago).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    It's not uncommon for a Windows program to scroll faster when you're constantly moving the mouse, but then it's usually the active window. It's possible that it affects other apps too though, I've never noticed. Also, I am aware of a graphics related activeX control that simulates sending spurious mouse move events to itself.
    Another possibility is that if the simulator only does work inside WM_PAINT message handling, then frequently causing the window to need to be redrawn could speed it up.
    One way or another, I'm sure if the effect that you're seeing is not a hallucenation, then it has got to be related to the Windows message queue.
    I recommend using Spy++ or other such similiar program to see what Windows messages are being sent to your simulator, and more specifically, what changes with the web-browser open to a certain page.
    Good luck!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Thumbs up Problem is finally solved!!

    Thank you guys (matsp & iMalc) for your commitment!

    It was actually you IMalc that lead us indirectly to the solution. You wrote "then it has got to be related to the Windows message queue". When I explained the problem to consultant that we engaged, and the just mentioned response from iMalc, he instantly said that it almost certain has to do with the Multimedia timer. It's obvious a common thing that particularly Flash animation increases the granularity of the Multimedia Timer in order to increase overall performance in windows i.e. more Windows messages are posted. As a test, we made a small program that increased the mentioned granularity and was started up just before our Simulator. It actually made our Simulator faster as it was with the mentioned home page in my first posted message above !!

    I hope that this information also can be useful for other developers, that struggles with applications that performs worse than expected, or the opposite, unexpectedly good, but only under unexpected circumstances!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Gnome) X Windows Application Issue
    By stickdeoderant in forum Linux Programming
    Replies: 0
    Last Post: 05-21-2007, 10:41 AM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21