# git module profiling

**URL:** <https://forum.ansible.com/t/git-module-profiling/16984>\
**Category:** Ansible Project\
**Created:** [December 8, 2014, 2:46pm UTC](https://forum.ansible.com/t/git-module-profiling/16984 "2014-12-08T14:46:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Spak](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@Josef\_Spak](https://forum.ansible.com/u/Josef_Spak)\
**Post date:** [December 8, 2014, 2:46pm UTC](https://forum.ansible.com/t/git-module-profiling/16984/1 "2014-12-08T14:46:42Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [December 8, 2014, 10:24pm UTC](https://forum.ansible.com/t/git-module-profiling/16984/2 "2014-12-08T22:24:10Z")

</div>

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](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](https://docs.python.org/2/library/timeit.html) and profile:  
[https://docs.python.org/2/library/profile.html](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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 9, 2014, 1:20pm UTC](https://forum.ansible.com/t/git-module-profiling/16984/3 "2014-12-09T13:20:44Z")

</div>

Can you please define slow and explain a bit about how you are testing it?
