none
Xperf does not display full stack - or maybe I am doing something wrong RRS feed

  • Question

  • Hello,

    I am new in using XPerf. I tried to see the performance problem spot by Xperf for a bad program like this:

    int func()
    {
        FILE * f = fopen("lala.txt", "w+");
        int c = 10;
        while(1)
        {
            fwrite(&c, sizeof(int), 1, f);
            fflush(f);
            fseek(f, 0, SEEK_SET);
            fread(&c, sizeof(int), 1, f);
            fseek(f, 0, SEEK_SET);
        }
        return 0;

    }
    int main()
    {
        return func();
    }

    I've started xperf like this:

    xperf -start perf!GeneralProfiles.InSequentialFile

    started my bad program named MoreCPU.exe, let it run for a while, and stop it. After that, i've stopped also xperf with:

    xperf -stop perf!GeneralProfiles.InSequentialFile trace_disk2.etl

    I've started to look at the etl file with Windows Performance Analyzer, it spot me that there is a CPU problem, but when I try to see the stack it looks like this:

    Process Stack Module Function DPC/ISR Weight % Weight Count TimeStamp
    MoreCPU.exe (172) 6374.811520 42.00 6376
    [Root] 6359.812487 41.90 6361
    |- MSVCR90.DLL!fread 2500.828797 16.48 2501
    |- MSVCR90.DLL!fflush 2464.139912 16.24 2465
    |- MSVCR90.DLL!fseek 1084.782407 7.15 1085
    |- MSVCR90.DLL!fwrite 151.992498 1.00 152
    |- ntkrpamp.exe!KiFastCallEntry 38.061644 0.25 38
    |- MSVCR90.DLL!_SEH_prolog4 28.996288 0.19 29
    |- MoreCPU.exe!func 21.999694 0.14 22
    |- MSVCR90.DLL!_lock_file 13.000008 0.09 13
    |- MSVCR90.DLL!_unlock_file 12.000947 0.08 12
    |- ntkrpamp.exe!KiRetireDpcList 11.004600 0.07 11
    |- halmacpi.dll!HalpIpiHandler 11.001467 0.07 11
    |- MSVCR90.DLL!_SEH_epilog4 4.000315 0.03 4
    |- NDIS.SYS!ndisMiniportIsr 2.003101 0.01 2
    |- ntkrpamp.exe!KiIpiServiceRoutine 2.000385 0.01 2
    |- ntkrpamp.exe!PerfInfoLogInterrupt 2.000383 0.01 2
    |- MSVCR90.DLL!_fseek_nolock 1.999932 0.01 2
    |- MSVCR90.DLL!fread_s 1.999932 0.01 2
    |- ntkrpamp.exe!EtwGetInterruptTimeStamp 1.999932 0.01 2
    |- ataport.SYS!IdePortInterrupt 1.999931 0.01 2
    |- pcmcia.sys!PcmciaInterrupt 1.000871 0.01 1
    |- ntkrpamp.exe!KiInterruptDispatch 1.000419 0.01 1
    |- MSVCR90.DLL!_fwrite_nolock msvcr90.dll Unknown Regular CPU Usage 0.999965 0.01 1 8.808210858
    |- MSVCR90.DLL!_fflush_nolock msvcr90.dll Unknown Regular CPU Usage 0.999059 0.01 1 7.035143264
    ? 14.999033 0.10 15

    So, it shows me that the problem is the number of the calls to fread, fwrite, fflush but is does not show me who call them - I would expect a stack like this:

    MoreCPU.exe -> Root -> MoreCPU.exe!main -> MoreCPU.exe!func -> MSVCR90.DLL!fread and so on

    As you can see in the table above it is able to display MoreCPU.exe!func so most probably the symbols are loaded also for my bad program.

    So, what can I change to see from where are called the three functions fread, fwrite, fflush from my bad program?

    Thank you - any help will be much appreciated.

    Mihai

    Sunday, July 22, 2012 11:36 AM

All replies

  • Hello,

    I have to add that I redo the test with the debug binary and the stack trace looks as it should. My problem is that in a real life scenario the problems I will have will be with the release binaries, so is there any way to fix the stack with the release binaries, also?

    Thank you,

    Mihai

    Sunday, July 22, 2012 1:08 PM