octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave profiler,


From: Muthiah Annamalai
Subject: Re: Octave profiler,
Date: Sat, 27 Jan 2007 07:20:06 -0600

On Thu, 2007-01-25 at 20:28 -0600, Muthiah Annamalai wrote:
> Hello there,
> 
> I was wondering if we could write a simple Octave profiler,
> modeled on Python interpreter & profiler setup.
> 
> 
> [Python Model]
> --------------
> Python allows user to set the profiling function, and this
> handle/function-ptr gets called for *every* C/Python function
> invocation, and return points. Python supplies the 'stack-frame', event
> type and additional arguments if any. 
> 
> Now event type can be any of 
> {c-call,c-return, c-exception, 
>  py-call,py-return, py-exception}.
> 
> One can set the handler using sys.setprofile(profile_fcn); where
> profile_fcn is defined as 
> 
> def profile_fcn(frame,event,arg):
>     # do something
> 
> In typical implementations,this function delegates events to particular
> handlers.
> 
> Essentially, we need to be able to provide a hookup like
> 'sys.setprofile' in Octave core, we may be able to profile calls to
> C/C++ , Fortran and Octave routines

I was wondering if the proper positions to insert hooks for invoking the
profiler would be at the point in subsref() member functions, before the
point where the code calls on do_multi_index_op() in the following
source files:

        Source File                     Profiler Events
---+-----------------------------+---------------------------------------
1       ov-mex-fcn.cc                   mex-call, mex-ret, mex-exception
2       ov-user-fcn.cc                  o-call, o-ret, o-exception
3       ov-mapper.cc                    mapper-call,mapper-ret,exception
4       ov-builtin.cc                   builtin-call,ret,exception

Will this be the proper places to add profiling code? I also want to
know if we will not have really bad overheads due to this. AFAIK other
languages (Ruby, Python) report about 30% overhead when using a
compiled-with-core profiler, that does a full call-graph profiling.

For Matlab compatibility, Octave needs such a call-graph based
profiling. Even if Octave uses just flat-profiling with just reporting
of number of calls, times for calls, Octave needs to provide the
profiler hook like I mentioned is done in Python (and in Ruby, with
set_profile_func ).

So, we need a hook function. But is this the right place to provide
them?

~ Muthiah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]