Macro and micro performance tuning

March 21st, 2005 at 8:32 am (3 years, 3 months ago) by Andi Vajda under chandlerdb

The focus of the repository work for Chandler’s 0.5 release was mostly about startup and commit performance. The approach taken was to run these operations in the hotshot profiler to find out more about the slow areas and rework them. This macro-performance effort can yield useful results. For instance, commit was made twice as fast by rewriting it to not use any XML.
For 0.6, I’d like to also look at performance at the micro-level.

A few months ago, Phillip Eby pointed me at python’s timeit module, another gem hidden somewhere in the vast python library.

This module allows to time small snippets of code and compare how they perform. It makes optimization by trial and error really easy.

For example, running these two statements on the command line
- python -m timeit -s “a={}” “0 in a”
- python -m timeit -s “a={}” “a.haskey(0)”
shows that the ‘in’ operator can be quite a bit faster than has
key(), its functional equivalent.

By using these techniques and moving some well chosen code to C, simple repository attribute access is now over four times faster.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit

Leave a Reply