Performance optimization is vital for Drupal core, especially as the content management system of choice for 1.7 million websites worldwide according to TechJury. Drupal 10.2 and newer come with the built-in performance testing framework Gander. Gander offers a systematic approach to identifying and resolving performance bottlenecks, ensuring Drupal core – and your Drupal installations – run efficiently. This innovative solution came about from combined efforts involving the Google Chrome team and Tag1 Consulting.

Curious about Gander and its potential impact on your workflows and site performance? This testing framework was instrumental in four important improvements made to Drupal core performance. Let’s break down each bottleneck and the solutions that led to these improvements.

1. Streamlining the Login Procedure

Using Gander, inefficient database queries in the user login and authentication process were identified. Issue #3410582 highlights that user logins triggered duplicate entity queries. First, the user name was checked via an entity query to confirm if it matched a blocked user. Then another entity query checked if the user name matched a not-blocked user before checking flood control by username. After the user name passed flood control, a call to UserAuth::authenticate() with the username and password reran the second entity query. The resolution for the duplicate entity queries had to take into consideration related issues #3425342 and #3410707, but it successfully reduced query times significantly. This enhancement of Drupal core led to a more responsive and efficient authentication process, which in turn improves the overall user experience.

2. Optimizing the Umami Demo Installation Profile

The Umami demo installation profile, used for demonstration and educational purposes within Drupal, was loading its main hero image twice. This redundancy not only affected the page load time but also had a negative impact on the Largest Contentful Paint (LCP) metric, a crucial factor for user experience and SEO performance. (See issue #3349447.)

Using Gander, the core contributors identified the cause of the problem and implemented a fix to ensure that the hero image loads one time. This was achieved through adjustments in the way Drupal handles the image loading process within the Umami demo profile.

The fix had a positive impact on the performance of websites using the Umami demo profile. By loading the hero image only once, the page load times were reduced, leading to a better user experience and improved LCP metrics for SEO ranking.

3. Improving BigPipe Requests

In BigPipe, a Drupal core module that can enhance website performance, redundant session data queries in the requests were causing delays in initial responses. Because BigPipe executed rendering after the initial response, session closure was necessary. However, this led to the system having to re-read session data, causing duplicate session read queries within a single request.

Gander detected the problem. To address this issue, the team focused on optimizing session data handling and implementing a static cache mechanism. By adding session data to a property on the session handler, the data could be retrieved if the session was read twice. Additionally, a new ResponseKeepSessionOpenInterface was introduced, enabling BigPipeResponse to implement session closure without the need to reload session data. This solution effectively streamlined BigPipe responses, eliminating redundant queries, minimizing queries, and enhancing overall system efficiency.

Implementing the solutions significantly improved Drupal’s performance for sites using the BigPipe module. By minimizing redundant session data queries, pages load faster and site responsiveness improves. (See issue #3414287.)

4. Refining Cache Tag Checking Function

Another issue detected by Gander was that Cache tags, responsible for managing cache invalidations, were inefficiently processed even when no actionable data was present. This resulted in unnecessary operations, contributing to increased CPU load and processing time. Issue #3422981 goes into more detail.

To address this issue, the developers introduced a mechanism to bypass unnecessary processing for empty arrays. By implementing early return logic, the system now skips processing cache tags when no actionable data is present, significantly reducing unnecessary operations.

This optimization not only streamlines cache tag handling but also contributes to overall site performance by alleviating CPU load and reducing processing time. This enhances the efficiency of Drupal's cache management system, ensuring smoother site operations for developers and site owners alike.

Gander Is Improving Drupal Core – And More

As these important Drupal core improvements demonstrate, Gander is a revolutionary tool now available as part of Drupal core. This powerful performance testing framework provides developers with sophisticated means to detect and, therefore, correct performance issues, marking a significant step forward for Drupal's performance optimization. For ongoing updates and insights into Gander's evolution, visit the Gander cornerstone page, where you'll find a wealth of resources dedicated to its development and application.

Ready to optimize your Drupal site's performance with Gander? Begin exploring its capabilities today by following the Quickstart guide in the official documentation.

Get the Scoop on Gander: Meet Us at DrupalCon Portland!

Join us at DrupalCon Portland for a deep dive into Gander on Tuesday, May 7, 2024, at 16:10 PDT in Room B117-119. We'll explain its motivation, basics, and demonstrate its use for Drupal Core development and on your own site. Don't miss out on the opportunity to be part of pushing the boundaries of what's possible with Drupal performance. We will also present Gander as part of the Drupal Project Initiatives Keynote on Wednesday, May 8, 2024, at 09:00 PDT in Room 201-203 Oregon Ballroom.

See you there!


Optimize your Drupal site performance with Gander

Photo by Gary Bendig on Unsplash