Improve the speed of datagrid rendering.

Review Request #1483 — Created March 24, 2010 and submitted — Latest diff uploaded

Information

Djblets
master

Reviewers

Improve the speed of datagrid rendering.

An earlier change drastically reduced query times by reducing the number of
queries made and cached object lookups, but datagrid rendering was still slow
due to the number of template loads and renders.

We now do a few things to speed up rendering.

1) We now load a cell template and parse it only once, instead of once per
   cell. Much of our time was spent in parsing the same template file over
   and over. By caching this parsed Template object and using it for all cells
   we have to render, we drastically cut down on the render time.

2) We do the same for header templates as well. This takes up far less time
   than cell template parsing, but is still a savings.

3) We keep a cached render of every distinct cell for the lifetime of the
   datagrid render. This means that if 20 cells all render the name of a
   User, we will only render that cell once, and pull it from the cache the
   19 other times.

4) While not datagrid-specific, the feedview app now imports feedparser only
   when needed. On my tests here, feedparser took a quarter of a second to
   load, so this is a decent savings.

All in all, on my test with 16 rows of 8 columns, this reduced load time
of the Review Board dashboard by just over a second. Larger datagrids should
get a proportional savings.
Tested this on my own internal test database and on a replica of the database on reviews.reviewboard.org. It was noticeably faster in both cases.