git module profiling

24 views
Skip to first unread message

Josef Špak

unread,
Dec 8, 2014, 9:46:42 AM12/8/14
to ansible...@googlegroups.com
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

Toshio Kuratomi

unread,
Dec 8, 2014, 5:24:14 PM12/8/14
to ansible...@googlegroups.com
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
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> 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.

Michael DeHaan

unread,
Dec 9, 2014, 8:20:49 AM12/9/14
to ansible...@googlegroups.com
Can you please define slow and explain a bit about how you are testing it?



Reply all
Reply to author
Forward
0 new messages