|Version 25 (modified by 16 months ago) ( diff ),|
Trac and Performance
This page collects Trac performance issues, solutions and troubleshooting.
When dealing with performance degradation on a Trac installation there are some potential causes to consider:
- a large number of plugins may add to the load in subtle ways
- the security model of TracFineGrainedPermissions
- the conditions in which Trac is run (web front-end)
- the specific configuration settings of Trac
- various bugs that might be triggered by any of the above
Check your installation
If Trac is not installed correctly, performance will suffer. The most obvious mistake is installing Trac as a CGI script. Even for testing, there are better alternatives, see tracd.
The second main installation mistake relative to performance would be to serve static resources through Trac. For best performance, Trac pages should be served by a web server, see TracInstall#MappingStaticResources.
Other points worth checking:
- When using mod_python, use at least version 3.3.1; prefer mod_wsgi (at least version 2.4), ie daemon mode.
- Running Trac under the QEMU virtualizer is slow (ticket:7490#comment:42).
- In Apache there is a possible issue when using mod_deflate (#8534, googlegroups:trac-users:ab070d251f5a0d11); however, some people have good results with mod_deflate and advise using it (TracDev/Performance/0.11.5).
- Some third party packages, such as Pygments, could also be responsible for heavy CPU loads; specifically, Pygments 1.0's scala mode (#392).
- Ensure an image has been configured as the Trac logo in the top left. The default install from Ubuntu 10.04 for example does not include a default logo and this makes pages slow to load.
Check your configuration
Several settings enhance Trac in one way or the other, but have a performance cost, which in some cases can be large. Other settings can help improve (perceived) performance.
default_daysbackset to a high value might introduce quite some load, depending on the activity. Pick an appropriate value for your site.
- the default
max_daysbackcan be inappropriate, eg allowing 90 days for a site with lots of activity might be too much. Don't hesitate to reduce it, especially now that Trac supports paging
- any setting other than
changeset_show_files = 0can be expensive, depending on the quantity of changesets to process
repository_sync_per_request(Trac < 1.2)
- Use of
trac_user_rlookupcan reduce performance if there are many users and the
cached_repositoryoption is disabled.
<name>.sync_per_requestoption (Trac ≥ 1.2).
Check your trac.log
Search for the following:
- INFO messages: Reloading environment due to configuration change
If you find lots of such lines, or even worse, if they appear systematically, then chances are that you're using a plugin which does systematic updates to the configuration file trac.ini, and this will in turn trigger a full environment reload at the next request. That can slow down the performance a lot, to the level of TracCgi. See ticket:7490#comment:102 and follow-up.
- INFO messages: rev  != cached rev  (other revision numbers for you, of course)
If you find such lines and the
cached revvalue doesn't change, this corresponds to a repository resync failure, which results in a resync attempt for every request (see ticket:7490#comment:36); often as a result of the "prohibited" MySQL/MyISAM combination (#8067).
- WARNING message: Slow mail submission
A mis-configured or simply slow mail server make Trac appear very slow (#3220).
- Excessive permission checks.
[trac] debug_sqland check DEBUG messages for excessive SQL queries.
- After the adoption of the Genshi template engine in Trac 0.11 in 2008, some associated performance issues were solved (#6614).
- In Trac 1.3 the Jinja template engine was adopted and performance is improved over Genshi (#12639).
- Many plugins still use Genshi templates, which are supported for compatibility until Trac 1.5.1.
- Plugins that use the
ITemplateStreamFilterinterface prevent the performance improvements gained by using Jinja.
- Use PostgreSQL or MySQL in an environment with many users to avoid lock contention.
- Otherwise consider using SQLite with connection string
sqlite:db/trac.db?journal_mode=wal&synchronous=offif tolerable. (#11967)
- There was a bug up to 0.11.4 which could cause 100% CPU usage once in a while on some platforms. See #7785, which was thought to be fixed in 0.11.5, but re-opened since.
- Some plugins seem to degrade performance, see TracDev/Performance/0.11.5.
- Trac's tickets regarding performance.
Profiling a Trac request
I've written a blog post on how I do basic profiling for Trac. It includes a simple script that I use to check single requests. Read it @ my blog.
See also: TracDev/Performance