There may be better methods but I'd just instrument the code to spit
out timestamps at various points in its run.  I'd use this method
because the git module invokes the git command line frequently so
chances are that one of the git command line calls is what's slow.
Putting some code to log the time around the calls to external git
will let you track down which call it is and also doesn't require you
to learn a lot of python to get started.

For doing this quick and dirty, I would use the python-q library which
does simplistic logging to $TMPDIR/q:  https://pypi.python.org/pypi/q
 With it you can put lines in your code like:

import q, time; q.q('before: %s' % time.time())
# [git module gets invoked]
q.q('after: %s' % time.time())

Then $TMPDIR/q on the box ansible is talking to will contain these timestamps.

If you want to get more involved, you can look into several modules
from the python stdlib including timeit
https://docs.python.org/2/library/timeit.html  and profile:
https://docs.python.org/2/library/profile.html  but these will require
learning a bit more python and probably aren't needed for the
granularity of this particular problem.

-Toshio

On Mon, Dec 8, 2014 at 6:46 AM, Josef Špak <[email protected]> wrote:
> Hello,
>
> I'm trying to find out why the git module is so incredibly slow.
>
> * I'd like to fix it if possible
> * I need a better profiling tool than eyeballing git module run in htop on
> the remote host.
>
> I tried https://github.com/rkern/line_profiler but I couldn't get anywhere,
> probably because I'm a python newbie.
>
> Would anyone be able give me a few pointers on how to profile ansible module
> code?
>
>
> Thanks,
>
> Josef
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2597e894-30e6-4ada-afb1-3e14fe37aa90%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG9juErTT8vEbo%2BL5%3D4p30c2eaXXxB%2B8qcDmLtca3Fg7YL7UzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to