[PATCH] Cygwin: New tool: cygmon

Mark Geisert mark@maxrnd.com
Tue Jun 15 08:48:45 GMT 2021

Hi Jon,

Jon Turney wrote:
> On 12/06/2021 07:46, Mark Geisert wrote:
>> This tool is a sampling profiler of Cygwin programs with their DLLs.
>> Presently its development is managed at https://github.com/mgeisert/cygmon.
>> Documentation of cygmon has been added to the usual doc/utils.xml file.
> Nice!
> How attached are you to the name?
> There's nothing cygwin specific about this (you could profile any Windows 
> executable), so does it really need 'cyg' in the name?
> It's a profiler, so what is 'mon' short for?

I (thought I) was sort of riding on the ancient separation in Unix between 
generating the data and displaying it.  Back to Unix v6 the generating was done by 
something with "mon" in the name.. monitor() in the C library syscalling profil() 
to generate the data and write it to the file mon.out.  The separate program 
'prof' read a mon.out file and the corresponding executable to display the data.

Over time mon.out -> gmon.out, and prof -> gprof.  I presume those happened with 
GNU involvement.

So for Cygwin, I riffed on "gmon" by making the data generator, a program in this 
case, 'cygmon'.  gprof still applies as the way to display the data.

> A more detailed review to follow.

I'm going over that review now.  Thanks!

>> There are a couple of one-line fixes to unrelated files for minor issues
>> noticed while implementing cygmon.  The files involved are gmon.c and
>> doc/utils.xml (one line not part of the cygmon updates to that file).
> Please submit the gmon fix as a separate patch, ideally with some commentary about 
> what it fixes.

Sure, will do.

>> diff --git a/winsup/doc/utils.xml b/winsup/doc/utils.xml
>> index 22bd86904..2f256d602 100644
>> --- a/winsup/doc/utils.xml
>> +++ b/winsup/doc/utils.xml
> [...]
>> +
>> +    <refsect1 id="cygmon-desc">
>> +      <title>Description</title>
>> +    <para>The <command>cygmon</command> utility executes a given program, and
>> +      optionally the children of that program, collecting the location of the
>> +      CPU instruction pointer (IP) many times per second. This gives a profile
>> +      of the program's execution, showing where the most time is being spent.
>> +      This profiling technique is called "IP sampling".</para>
> Contrasting this with how 'ssp' profiles (and vice versa there) would be nice.

Good idea.  Will do.

>> +
>> +    <para>A novel feature of <command>cygmon</command> is that time spent in
>> +      DLLs loaded with or by your program is profiled too. You use
>> +      <command>gprof</command> to process and display the resulting profile
>> +      information. In this fashion you can determine whether your own code,
>> +      the Cygwin DLL, or another DLL has "hot spots" that might benefit from
>> +      tuning.</para>
>> +
>> +    <para> Note that <command>cygmon</command> is a native Windows program
>> +      and so does not rely on the Cygwin DLL itself (you can verify this with
>> +      <command>cygcheck</command>). As a result it does not understand
>> +      symlinks in its command line.</para>
>> +    </refsect1>



More information about the Cygwin-patches mailing list