Sergey,

I suspect that what you are seeing has nothing to do with printf buffering.
The line is flushed out on \n.

What you are seeing is a side effect of monitoring probably lots of
threads + aggregation.
There is no output until a sampling buffer fills up. With
--smpl-entries=1, they fill up quickly
but you may have lots of threads.

On Thu, Jul 9, 2009 at 11:23 PM, Sergey Blagodurov<blagodu...@gmail.com> wrote:
> Hello,
>
> I was wondering if it's somehow possible to obtain the output from
> pfmon unbuffered during sampling.
>
> What I want to do is to monitor a program's miss rate in real time
> with pfmon using the following invocation:
>
> pfmon --attach-task <pid of the program to monitor>
> --smpl-module=compact --smpl-entries=1 --long-smpl-periods=100000000
> --follow-all --aggregate-results -0 -3
> -eUNHALTED_CORE_CYCLES,L2_LINES_IN:SELF
>
> When I type it in the terminal, all is fine and strings for each
> sample show up in real time as soon as they are available.
>
> Problems start when I try to obtain the same results within c program.
> For that I create pipe and then redirect pfmon's stdout into this
> pipe. in this case, the results show not in real time, but buffered as
> 4k blocks, i.e. only after a block is full, it's being shown on the
> other side of the pipe. The same output with delays between the blocks
> can be obtained by issuing the following command:
>
> pfmon --attach-task <pid of the program to monitor>
> --smpl-module=compact --smpl-entries=1 --long-smpl-periods=100000000
> --follow-all --aggregate-results -0 -3
> -eUNHALTED_CORE_CYCLES,L2_LINES_IN:SELF | cat
>
> or by writing into the sample file with --smpl-outfile option:
>
> pfmon --attach-task <pid of the program to monitor>
> --smpl-module=compact --smpl-entries=1 --long-smpl-periods=100000000
> --follow-all --aggregate-results -0 -3
> -eUNHALTED_CORE_CYCLES,L2_LINES_IN:SELF --smpl-outfile=pfmon.log
>
> At first I thought that the problem is in the pipe itself. However,
> the output from some other commands doesn't have this same feature.
> For example, the following command brings lines as soon as they appear
> without any kind of buffering:
>
> ping 127.0.0.1 | cat
>
> Any ideas how I can solve this issue are greatly appreciated.
>
> Thank you!
>
> --
> Sincerely,
>
> Sergey Blagodurov
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> perfmon2-devel mailing list
> perfmon2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perfmon2-devel
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to