Page MenuHomePhabricator

Quibble and Fresnel web server should support gzip for static files
Closed, ResolvedPublic

Description

As of T219694, MediaWiki responses in Quibble and Fresnel now support Gzip. This makes index.php and load.php responses there more like production and thus Fresnel results more accurate of what end-users will perceive.

However, as part of working on T121730 I noticed that when changing a reference from being served from load.php to a static file, that its size increased notably by about 30%, which suggests gzip isn't applied here.

I confirmed this locally by running the following from a MediaWiki core checkout:

php -d 'output_buffering=Off' -S localhost:9412 maintenance/dev/includes/router.php

And e.g. accessing http://localhost:9412/skins/Vector/images/unwatch-icon.svg, confirming in the browser that it does not have a compressed response.

Event Timeline

Change 539427 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] maintenance: Enable gzip in router.php for static files

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

Fresnel results from https://gerrit.wikimedia.org/r/525840, without the above patch applied:

Before
22:42:21 ### scenario View history of a page
…
22:42:21 |   Total size of transfers during page load (pageWeight)  |      234 kB (± 1 B) |    237 kB (± 152 B) | + 2.6 kB | ✘ |
22:42:21 |   Transfer size of CSS resources (css)                   |     21.2 kB (± 0 B) |     19.1 kB (± 0 B) | - 2.1 kB | ✓ |
22:42:21 |   Transfer size of Image document (img)                  |     28.1 kB (± 0 B) |   33.0 kB (± 152 B) | + 4.7 kB |   |
22:42:21 
22:42:21 ### scenario View recent changes
22:42:21 |   Total size of transfers during page load (pageWeight)  |      269 kB (± 1 B) |      272 kB (± 1 B) | + 2.1 kB | ✘ |
22:42:21 |   Transfer size of CSS resources (css)                   |     11.6 kB (± 0 B) |      9.6 kB (± 0 B) | - 2.0 kB | ✓ |
22:42:21 |   Transfer size of Image document (img)                  |     28.1 kB (± 0 B) |     32.2 kB (± 0 B) | + 4.1 kB |   |

.. and after rebasing on top of the router.php gzip fix (Patch Set 1: gzip everything):

After (Patch Set 1)
23:07:47 ### scenario View history of a page
23:07:47 |   Total size of transfers during page load (pageWeight)  |      234 kB (± 1 B) |    237 kB (± 206 B) | + 2.3 kB | ✘ |
23:07:47 |   Transfer size of CSS resources (css)                   |     21.2 kB (± 0 B) |     19.1 kB (± 0 B) | - 2.1 kB | ✓ |
23:07:47 |   Transfer size of Image document (img)                  |     28.3 kB (± 0 B) |   32.9 kB (± 206 B) | + 4.4 kB |   |
23:07:47 
23:07:47 ### scenario View recent changes
23:07:47 |   Total size of transfers during page load (pageWeight)  |   270 kB (± <0.5 B) |   271 kB (± <0.5 B) | + 1.5 kB | ✘ |
23:07:47 |   Transfer size of CSS resources (css)                   |     11.6 kB (± 0 B) |      9.6 kB (± 0 B) | - 2.0 kB | ✓ |
23:07:47 |   Transfer size of Image document (img)                  |     28.3 kB (± 0 B) |     31.8 kB (± 0 B) | + 3.5 kB |   |

This shows the patch is working, and gzip is making things better. But the results are still not great. Net transfer size here is larger with the files served separately than embedded. This was a known risk going in and might be inevitable. But, I'm not giving up yet.

Rebasing on router.php gzip fix – Patch Set 4: only gzip non-binary content > 150 bytes; same as prod:

After (Patch Set 4)
23:46:19 ### scenario View history of a page
23:46:19 |   Total size of transfers during page load (pageWeight)  |      234 kB (± 1 B) |   233 kB (± <0.6 B) |  - 766 B | ✓ |
23:46:19 |   Transfer size of CSS resources (css)                   |     21.2 kB (± 0 B) |     19.1 kB (± 0 B) | - 2.1 kB | ✓ |
23:46:19 |   Transfer size of Image document (img)                  |     28.2 kB (± 0 B) |     29.5 kB (± 0 B) | + 1.3 kB |   |
23:46:19 
23:46:19 ### scenario View recent changes
23:46:19 |   Total size of transfers during page load (pageWeight)  |   269 kB (± <0.8 B) |   268 kB (± <0.4 B) |  - 971 B | ✓ |
23:46:19 |   Transfer size of CSS resources (css)                   |     11.6 kB (± 0 B) |      9.6 kB (± 0 B) | - 2.0 kB | ✓ |
23:46:19 |   Transfer size of Image document (img)                  |     28.2 kB (± 0 B) |     29.2 kB (± 0 B) |  + 986 B |   |

With that optimisation applied, it smaller overall, even on the bottom line. Everybody wins. (Mainly due to the bytes > 150 filter as trying to gzip the SVGs smaller than that actually tend to grow instead of shrink. This matches Varnish production config.)

Krinkle triaged this task as High priority.
Krinkle moved this task from Inbox, needs triage to Blocked (old) on the Performance-Team board.

Change 539427 merged by jenkins-bot:
[mediawiki/core@master] maintenance: Enable gzip in router.php for static files

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