Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293910

Create the database driver for MySQLi for async queries

$
0
0

Problem/Motivation

Running database queries as async queries lets us run them in parallel instead of sequentially. For pages with multiple "larger" queries this can speed up rendering such a page significantly. The problem is that the 3 by core supported database driver are all PDO drivers which do not support async queries. The PHP MySQLi extension does support async queries.
The other thing we need is PHP 8.1 with the Fiber functionality. Creating a database driver for MySQLi is the first step we need to make to start using async queries in Drupal.

@catch explained it as following:

Let's take something like https://www.drupal.org/dashboard - there's four or five different views on there in blocks.

If you hit a completely cold cache, you have to execute all the views building those blocks, including both the listing query, then rendering the entities within them.

The idea being explored is that for each lazy builder - let's assume we're able to loop over them, you'd render it up until you have to run a views listing query. When it's time to run that query (or whatever appropriate point to delegate to the Fiber), it's done inside a Fiber with a non-blocking query. You then ::suspend() the Fiber and return to the main process, and start the next lazy builder, if that also has to run a views listing query, you'd also run it non blocking and ::suspend(), then you loop over all the lazy builders again to see if the various queries have come back, then render the results for anything that has, then continue polling until everything is rendered.

The page still can't finish rendering until the slowest query is finished, but if you have five slow queries that take 500ms each, then you might be able to run them all at once in the space of 600ms-1s instead of definitely having to run them sequentially in 2.5s. While you're running those simultaneous queries, you can also get on with PHP/CPU-intensive tasks like rendering - assuming we're able to arrange things so that these can be interleaved.

Fibers only allow us to paralellize i/o, not CPU, because there's not any parallel execution at all, so it has to be something like an async MySQL or SOLR query or http request to make any difference, and there has to be something to be getting on with while it's running - either more i/o or something else.

Proposed resolution

For adding the MySQLi database driver we need the following:

  1. Create the MySQLi database driver which should extend the MySQL database driver.
  2. Add the PHP MySQLi extension as a requirement to the core MySQL and MySQLi database drivers.
  3. #3256642: Autoload classes of database drivers modules' dependencies which makes extending one database driver on another database driver a lot easier.

Remaining tasks

TBD

User interface changes

TBD

API changes

None

Data model changes

None

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 293910

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>