Page MenuHomePhabricator

Investigate if database setups is following best practices for speed
Closed, ResolvedPublicSpike

Description

Lets spend some time investigating if MySQL and SQLite is setup following best practices for speed. For PostgreSQL we have T422110. Check best practices documents for switches and turn off things that aren't needed, if we are using persistent connection etc. For all changes, try to measure it locally to see if the change actually will be a performance win,

Acceptance Criteria:

  • Look at the MySQL setup in Quibble, are we following MySQL best practices? Is there anything we can do to speed up the database?
  • Look at the SQLite setup in Quibble, are we following SQLite best practices? Is there anything we can do to speed up the database?

Event Timeline

Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptApr 12 2026, 6:21 AM

For MySQL when I run the test locally on my machine and enable persistent connections, I get a little bit over 10% performance improvement. Then changing how each database saves the transaction log (not saving per commit, instead use a time interval) seems to make each job much faster, we could probably save 30% there. Let me create follow up tasks to implement the changes.

Change #1270277 had a related patch set uploaded (by Phedenskog; author: Phedenskog):

[integration/quibble@master] mysql: Disable the redo log for every commit

https://gerrit.wikimedia.org/r/1270277

Change #1270277 abandoned by Phedenskog:

[integration/quibble@master] mysql: Disable the redo log for every commit

Reason:

I cannot quantify that this will actually increase the performance

https://gerrit.wikimedia.org/r/1270277

Ok, I've been trying out different things the latest days. First: testing locally on my machine didn't work out, those metrics was to unstable. Pushing to a dedicated instance works better. I used one instance with 16 VCPUs and 16 gb RAM.

This is what I've tested that didn't get any results. All testing did three baseline runs and three measurements.

Mysql

  • Overall: mounting the database to memory made all configuration tests no win at all. It seems the bottleneck is not the db. Things I tried:
    • innodb_flush_log_at_trx_commit=0 — reconfirmed on VM over 3 runs: no benefit. fsync is already a no-op on tmpfs.
    • DBO_PERSISTENT (persistent connections)
    • Aggressive SET GLOBAL combo (flush=0 + doublewrite=OFF + io_capacity + stats_on_metadata)
    • MySQL memory isolation sweep — 10 variants via patched backend.py startup flags. None clearly outside ±9% single-run noise:
      • --innodb-buffer-pool-size=512M / =1G / =2G
      • --innodb-buffer-pool-instances=4
      • --tmp-table-size=64M --max-heap-table-size=64M
      • --skip-log-bin
      • --innodb-stats-on-metadata=0
      • --innodb-log-file-size=256M
      • --innodb-adaptive-hash-index=0
      • --innodb-change-buffering=none

PostgreSQL
I tried a couple of different settings:

  • synchronous_commit=off alone — noise / no-op on tmpfs.
  • PGOPTIONS='-c jit=off'
  • DBO_PERSISTENT / pg_pconnect
  • pgbouncer (transaction pooling)
  • I upgraded to v17 (we use v13 in CI) it was actually 3% slower. Tried to tune 17 but no luck

SQLite

  • No specific tuning. I tried creating one SQLite per phpunit worker. That worked in a way and get test 2,8 times faster but there where tests CleanupWatchlistLabelMemberTest that failed. So to go on that path we need to invest more time.

Conclusion: Databse/ CI runtime on tmpfs is dominated by PHP startup / schema setup / test-case cost, not DB path cost. DB tuning cannot move this workload.

Change #1270218 abandoned by Phedenskog:

[integration/quibble@master] mysql: Disable the redo log for every commit

https://gerrit.wikimedia.org/r/1270218

Change #1270215 abandoned by Phedenskog:

[integration/quibble@master] mysql: Disable the redo log for every commit

https://gerrit.wikimedia.org/r/1270215

Change #1270237 abandoned by Phedenskog:

[integration/quibble@master] postgres: Flush async

https://gerrit.wikimedia.org/r/1270237

Change #1270217 abandoned by Phedenskog:

[integration/quibble@master] mysql: Disable the redo log for every commit

https://gerrit.wikimedia.org/r/1270217

Change #1270216 abandoned by Phedenskog:

[integration/quibble@master] mysql: Disable the redo log for every commit

https://gerrit.wikimedia.org/r/1270216