Performance

Last updated on
9 July 2025

Discussion: Defining the Drupal 8 performance gate

SQL queries

When is this needed?

If there is a new or changed SQL query in a patch

Details

Changes that add or modify SQL queries should include: EXPLAIN output, description of indexes added or changed, indication of how often the query is likely to run and under what circumstances. The goal is not to add additional database calls unless absolutely necessary, and to ensure that all queries scale when using large data sets (avoiding scanning large numbers of rows, filesorts, temporary tables etc.)

Resources

Devel module, MySQL EXPLAIN documentation

Caches

When is this needed?

Add a cache only when slowness has been demonstrated. If a contrib module or core module could be slow in some cases, add caching strictly for the part that is slow.

Details

Caches degrade developer and admin experience. It gets very hard to clear them during all the right moments, given how flexible Drupal is. Cache invalidation is a huge, complex topic in computer science. We are best off avoiding caches when possible. Static caches are only slightly less evil than persistent caches.

Resources

Memory usage

When is this needed?

If a patch changes or adds any resource that is statically cached or in a global, or involves changes to cache/registry rebuilds

Details

Ideally post before/after xhprof detail for the area of code being modified. Devel memory usage information may be sufficient

Resources

xhprof, devel, xdebug trace files

CPU

When is this needed?

If a patch adds or changes any code that is run during a 'normal' request to Drupal, especially up to and including full bootstrap, or during the page rendering process

Details

Ideally post before/after xhprof or cachegrind detail for the area of code being modified. In some cases benchmarks via ab or another load testing tool may be sufficient.

Resources

xdebug, devel

System calls

When is this needed?

If a patch adds or modifies include/require, file_exists()/file_mtime(), time() calls during normal operation or cache rebuilds

Details

Post before/after xhprof, cachegrind or strace detail for the area of code being modified.

Resources

Strace, xhprof, xdebug

Front end

When is this needed?

If a patch makes significant changes to JavaScript or CSS

Details

If refactoring commonly used JavaScript, post profiling data (not sure on tools). If changing JavaScript and/or CSS aggregation logic, size and number of aggregates across several page requests should be posted to the issue

Resources

google chrome toolbar, firebug

Help improve this page

Page status: No known problems

You can: