profiling cygwin itself

jojelino jojelino@gmail.com
Sun Mar 6 14:41:00 GMT 2011


hi
i'm digging for cygwin to make it profiling itself. and i got some 
result which regards to it.
the attachment could be applied making cygwin profiling itself.
the problem is i don't know whether i'm doing it right way.
hence you can point out which would be other way.

current http://www.cygwin.com/profiling/ document are some kind of old 
stuff.
hence it took some time...

current profiling facility (profthr_func) seems to be missing useful 
call enter/exit information so much. because cygwin does many job during 
10ms ;)

by the way, gcc supports instrument-function, which hooks function 
call/exit. so i gave novice implementation for those hooks.

and this instrument function is visited by several threads, i 
copy-pasted some code which does bound-buffer queue operation. hence any 
enqueue request will be processed in order.

also i have to add some hard-coded ctor function at dll_entry, and alter 
when atexit(_mcleanup) is called.

and finally, added DLL_OFILES:=gcrt1.o gmon.o profil.o mcount.o 
$(DLL_OFILES) above ifneq "${filter -O%,$(CFLAGS)}" ""
in Makefile

and make,

make CFLAGS='-O2 -pg -finstrument-functions -g -Wno-error=uninitialized 
-Wno-error=unused-but-set-variable -Wno-error=unused-function';
s='malloc_wrapper.o kernel32.o boundbuffer.o instrument.o gmon.o 
mcount.o profil.o gcrt1.o';rm $s; make $s CFLAGS='-O2 -g 
-Wno-error=uninitialized -Wno-error=unused-but-set-variable 
-Wno-error=unused-function';make

and testcase follows, compile it without -pg.

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
int main()
{
	sem_t s;
	dassert(sem_init(&s,1,0)>=0);
	pid_t pid=fork();
	if (pid>0)
	{
	printf("spawned %d\n",pid);
	sem_post(&s);
	}
	else if (pid==0)
	{
	sem_wait(&s);
	printf("child\n");
	}
	else
	{
	printf("error\n");
	}
}

finally gmon.????.out has come out, but i think i did something wrong. 
any suggestion would be appreciated.

===================================================
Flat profile:

Each sample counts as 0.01 seconds.
   %   cumulative   self              self     total
  time   seconds   seconds    calls   s/call   s/call  name
  28.78    429.49   429.49        4   107.37   107.37 
_cygtls::init_thread(void*, unsigned long (*)(void*, void*))
  28.78    858.98   429.49        1   429.49   429.49  strace::active() 
const
  28.78   1288.47   429.49 
exception::exception()
  13.65   1492.09   203.62 
pinfo::operator->() const
   0.00   1492.09     0.00      512     0.00     0.00 
mtinfo_part::initialize(long)

=====================================================

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: profile-self.diff
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110306/17fe67df/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygwin1.dll.result
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110306/17fe67df/attachment-0001.ksh>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list