Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4995 Discussions

Can VTune focus in on a specified time interval?

mcmurdocki
Beginner
541 Views
Hello,
I recently downloaded VTune to see if it could help me resolve a problem I am having in my Visual Studio 7/C++ application. However, the seven day trial period expired before I could really dig into VTune and see if it could help. So I thought I would briefly describe my problem and hopefully someone can tell me that VTune can solve this problem and then I can justify the purchase to my boss.
My Application.
My application is a Windows C++ ActiveX video player that is "activated" from a web page and plays an audio+video clip pulled of a network. I use Windows Media SDKs to decode the audio and video tracks and I use the
Windows multimedia SDK for rendering the audio track. But I have had towrite a video renderer that takes buffers of images and paints them on the screen one frame at a time.
My Bug.
My media player works fine except in the very reproducible condition in which I have the player do some TCP connection stuff like HTTP requests for more media content from a remote web server. When these network requests are going on the OS thread scheduler seems to do something that makes it appear that it gets behind on my video rendering thread and so all of a sudden it will do something strange. I have an OS thread running a timer that is supposed to call back at a set interval, at which point I paint one video frame on the screen. Shortly after the network activity occurs, I suddenly get a rapid rendering of a sequence of about 15 or 20 frames and then things go back to normal. Although the timer I am using is not giving me accurately-timed callbacks, it does not seem to be the culprit. I call a gdi function called bitblt that does the actual painting of the bits on the screen. And it appears that my calls to bitbltseem to be getting "cached" by the thread scheduler such that even though the bitblt calls are happening at (somewhat) appropriate time intervals, the thread scheduler goes off to service other threads and when it comes back to my thread it performs several bitblts one right after another at very short time intervals like it's trying to catch up. As you can tell, I don't really know what is going on. I can only describe what I am seeing and what my interpretation is.
Where Does VTune Fit In to My Sad Story.?
I used VTune a long time ago but I never learned all of its feature and capabilities. I never used it to help me (deeply) understand what is going on in my program from say, 30 seconds to 45 seconds after it starts, or say, 3 seconds after some triggering event. I need to know if I can use VTune to focus in on a particular window of time after some triggering event occurs to see what threads and modules are running during this interval. Can VTune do this? If so, could you point me to some documentation that describes how I configure VTune to do this kind of analysis?
0 Kudos
3 Replies
David_A_Intel1
Employee
541 Views

There are a couple of features that could be used in this case. One is the Pause/Resume API, which would allow you to start collecting data when you wanted to (i.e., you add a call in your code to resume data collection and start the activity with data collection paused). The other is the Samples Over Time feature, which displays the number of samples collected within time slots. You can zoom in so that the time slots become finer and finer. Check out the online help for details.

What kind of timer are you using? You know that WM_TIMER messages have a low priority, right? As I understand it, multimedia timers are preferred for your type of application.

0 Kudos
mcmurdocki
Beginner
541 Views

Thanks for responding and for your ideas.

I did not know about the Pause/Resume API, which sounds like it would be a perfect fit. I have to confess I was not even aware that there existed VTune APIs. But it sounds like I would start out by calling "Pause" and then when my code detects the start of the condition causing me problems, my code makes a "Resume" call and then about 2 seconds later, my code could "Pause" again. And this sequence of pausing and resuming would make VTune only focus on the activity when not paused. Also, I'm assuming that the Pause/Resume functionality is done with some sort of C or C++ call into a VTune library that Ilink my application against.

Does all this sound correct?

Does this VTune library come as part of the VTune for Windows package or is it a separate product/purchase?

With regards to your question about my timer, I am calling timeSetEvent from Microsoft's Multimedia PlatformSDK with the resolution set to 1 (for most accuracy), the delay set to 33 mS, and the flags are set to TIME_PERIODIC | TIME_CALLBACK_EVENT_SET, which means that every 33 mSec the event I specify should get signaled. My events get signaled with a periodicity of anywhere from 20 to 60 mSec as measured with calls to GetSystemTimeAsFileTime. I have no idea what I am doing wrong to make the timing of the timeSetEvent callbacks so inaccurate. BTW, the priority of the CWinThread method that calls the timeSetEvent function is created as THREAD_PRIORITY_HIGHEST. But I don't think this helps since the timeSetEvent code runs in its own OS-created thread, which I can't control or improve its priority.

Thanks again for your help.

0 Kudos
David_A_Intel1
Employee
541 Views

Michael:

The Pause/Resume APIs are included with the product and are documented in the online help. Please review the online help for complete information.

Regards,

0 Kudos
Reply