Page MenuHomePhabricator

Convert SyntaxHighlight to use Shellbox
Closed, ResolvedPublic

Description

SyntaxHighlight shells out to Pygments to highlight stuff. There are 3 primary things that need to be converted:

  • Getting the generated CSS
  • Getting the language list
  • Actually doing the syntax highlighting

Currently the first two are just hardcoded, and can probably remain that way if it's using the bundled pygments. Otherwise it should call shellbox to avoid version mismatches.

Related: T271751: SyntaxHighlight extension is slow (needs more active stewardship).


  • Review charts
  • shellbox-syntaxhighlight namespaces in k8s
  • shellbox-syntaxhighlight accounts in k8s.
  • shellbox-syntaxhighlight puppet private tokens.
  • Generate TLS certificates
  • Review helmfile.d files:
  • LVS setup
  • DNS for LVS records
  • Discovery DNS
  • Monitoring dashboard
  • Integration and Acceptance tests

Details

SubjectRepoBranchLines +/-
operations/deployment-chartsmaster+8 -1
operations/deployment-chartsmaster+1 -1
operations/mediawiki-configmaster+1 -0
operations/mediawiki-configmaster+11 -0
operations/mediawiki-configmaster+6 -0
operations/puppetproduction+18 -0
operations/dnsmaster+6 -0
operations/puppetproduction+3 -3
operations/puppetproduction+3 -3
operations/puppetproduction+3 -3
operations/puppetproduction+120 -0
operations/dnsmaster+15 -2
operations/deployment-chartsmaster+65 -0
mediawiki/extensions/SyntaxHighlight_GeSHimaster+382 -81
mediawiki/libs/Shellboxmaster+15 -0
operations/deployment-chartsmaster+1 -0
operations/puppetproduction+20 -0
labs/privatemaster+24 -0
Show related patches Customize query in gerrit

Event Timeline

Change 716048 had a related patch set uploaded (by Legoktm; author: Legoktm):

[labs/private@master] Add k8s users/tokens for shellbox-{syntaxhighlight,timeline}

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

Change 716051 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] Add k8s tokens/users for shellbox-{syntaxhighlight,timeline}

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

Change 716048 merged by Legoktm:

[labs/private@master] Add k8s users/tokens for shellbox-{syntaxhighlight,timeline}

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

Change 716051 merged by Legoktm:

[operations/puppet@production] Add k8s users/tokens for shellbox-{syntaxhighlight,timeline}

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

Change 716054 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/deployment-charts@master] admin: Add namespace for shellbox-syntaxhighlight

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

Change 716054 merged by jenkins-bot:

[operations/deployment-charts@master] admin: Add namespace for shellbox-syntaxhighlight

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

My plan is to have SyntaxHighlight effectively split into two modes: using bundled and not bundled (this is similar to what Scribunto's LuaStandalone does).

In bundled mode:

  • The version of pygments will be hardcoded
  • The CSS is read from the bundled stylesheet, using a ResourceLoaderFileModule
  • The lexer list is read from the bundled PHP data file

In not-bundled mode (what Wikimedia will use):

  • The version of pygments will be fetched by parsing pygmentize -V, and cached for an hour in apcu
  • The CSS is read by shelling out, using a custom ResourceLoaderModule. Unclear if it'll need additional caching here on top of RL's caching
  • The lexer list is read by shelling out, cached for a day in apcu, keyed on the cached version.

The actual highlighting will use BoxedCommand, cached on version (new) in WAN for 1 month (pre-existing). To keep things relatively simple I'm not planning on adding abstraction for all of this, but it should be straightforward for someone to refactor in the future for adding a microservice backed highlighter.

Change 716756 had a related patch set uploaded (by Legoktm; author: Legoktm):

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] [WIP] Port to BoxedCommand

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

Change 717020 had a related patch set uploaded (by Legoktm; author: Legoktm):

[mediawiki/libs/Shellbox@master] pipeline: Build image for SyntaxHighlight with Pygments

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

Change 717020 merged by jenkins-bot:

[mediawiki/libs/Shellbox@master] pipeline: Build image for SyntaxHighlight with Pygments

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

Change 720378 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/deployment-charts@master] helmfile.d: Add shellbox-syntaxhighlight

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

Change 716756 merged by jenkins-bot:

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Port to BoxedCommand

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

Change 720378 merged by jenkins-bot:

[operations/deployment-charts@master] helmfile.d: Add shellbox-syntaxhighlight

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

Change 721904 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] Add LVS for new Shellboxes: media, syntaxhighlight & timeline

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

Change 721905 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] service: Switch new Shellboxes to lvs_setup

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

Change 721906 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] service: Switch new Shellboxes to monitoring_setup

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

Change 721908 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/dns@master] Add *.svc.{codfw,eqiad}.wmnet entries for new Shellboxes

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

Change 721907 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] service: Switch new Shellboxes to production

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

Change 721909 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/dns@master] Add new Shellboxes to discovery

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

Change 721908 merged by Legoktm:

[operations/dns@master] Add *.svc.{codfw,eqiad}.wmnet entries for new Shellboxes

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

Change 721904 merged by Legoktm:

[operations/puppet@production] Add LVS for new Shellboxes: media, syntaxhighlight & timeline

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

Change 721905 merged by Legoktm:

[operations/puppet@production] service: Switch new Shellboxes to lvs_setup

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

Change 721906 merged by Legoktm:

[operations/puppet@production] service: Switch new Shellboxes to monitoring_setup

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

Change 721907 merged by Legoktm:

[operations/puppet@production] service: Switch new Shellboxes to production

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

Change 721909 merged by Legoktm:

[operations/dns@master] Add new Shellboxes to discovery

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

Change 722736 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/puppet@production] services_proxy: Add envoy proxies for new Shellboxes

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

Change 722737 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/mediawiki-config@master] ProductionServices: Add new Shellboxes

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

Change 722736 merged by Legoktm:

[operations/puppet@production] services_proxy: Add envoy proxies for new Shellboxes

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

Change 722737 merged by jenkins-bot:

[operations/mediawiki-config@master] ProductionServices: Add new Shellboxes

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

Change 723049 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/mediawiki-config@master] Have SyntaxHighlight use Shellbox service on group0 wikis

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

Change 723049 merged by jenkins-bot:

[operations/mediawiki-config@master] Have SyntaxHighlight use Shellbox service on group0 wikis

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

Mentioned in SAL (#wikimedia-operations) [2021-09-23T08:02:54Z] <legoktm@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Have SyntaxHighlight use Shellbox service on group0 wikis (1/2) (T289227) (duration: 01m 06s)

Mentioned in SAL (#wikimedia-operations) [2021-09-23T08:04:16Z] <legoktm@deploy1002> Synchronized wmf-config/CommonSettings.php: Have SyntaxHighlight use Shellbox service on group0 wikis (2/2) (T289227) (duration: 01m 05s)

SyntaxHighlight on group0 is now running via the Shellbox service.

If it goes well over the next few days and weekend we can roll it out further next week.

For some reason I see no hits for fetchGeneratedCSS() in statsd nor exec.log. It should've been called at least once and then stored in WAN cache...

For some reason I see no hits for fetchGeneratedCSS() in statsd nor exec.log. It should've been called at least once and then stored in WAN cache...

I now see 1 entry (logstash id DXvSEXwB9aenX452ZvP6), maybe was waiting on some RL cache to expire? Things look fine (visually) though!

Change 724198 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/mediawiki-config@master] Have SyntaxHighlight use Shellbox on group1 wikis too

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

Change 724198 merged by jenkins-bot:

[operations/mediawiki-config@master] Have SyntaxHighlight use Shellbox on group1 wikis too

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

Mentioned in SAL (#wikimedia-operations) [2021-09-27T22:34:43Z] <legoktm@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Have SyntaxHighlight use Shellbox on group1 wikis too (T289227) (duration: 00m 57s)

Change 724203 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/deployment-charts@master] Bump shellbox-syntaxhighlight up to 6 replicas

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

Change 724203 merged by jenkins-bot:

[operations/deployment-charts@master] Bump shellbox-syntaxhighlight up to 6 replicas

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

Things look relatively stable now \o/. I also wrote up https://www.mediawiki.org/wiki/Extension:SyntaxHighlight/Updating_pygments which explains the new process for upgrading pygments.

I think things can still be tuned a bit further, I'll keep watching it.

It looked pretty bad on the Shellbox side too: https://grafana.wikimedia.org/d/RKogW1m7z/shellbox?orgId=1&var-dc=eqiad%20prometheus%2Fk8s&var-service=shellbox&var-namespace=shellbox-syntaxhighlight&var-release=main&from=1632906027990&to=1632909636707

Per https://grafana.wikimedia.org/d/vcOTDuSnk/syntaxhighlight?orgId=1&from=1632906048981&to=1632907839781 MediaWiki sent 1300 highlight requests in a minute. Zooming out over the past 24 hours I do see spikes reaching over 1200 at other times. Let me do a bit of napkin math and increase the replica count.

@TheDJ I'm curious if you were just looking at the dashboards and noticed that or if you or someone else experienced page loading/saving being slow.

I was going through my phab notifications. I was looking at https://phabricator.wikimedia.org/T271751 and this ticket around the same time. And opened https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples and then some time later I looked at the graph link you posted in this ticket. They could be related I guess but I didn't experience any slowness or anything, so i didn't consider the option of them being related.

That page is like the worst case performance example for SyntaxHighlight :)

A few hours ago we also had:
16:37:33 <+icinga-wm> PROBLEM - LVS shellbox-syntaxhighlight eqiad port 4014/tcp - Shellbox SyntaxHighlight- shellbox-syntaxhighlight.svc.eqiad.wmnet IPv4 on shellbox-syntaxhighlight.svc.eqiad.wmnet is CRITICAL: CRITICAL - Socket timeout after 10 seconds https://wikitech.wikimedia.org/wiki/LVS%23Diagnosing_problems
16:39:33 <+icinga-wm> RECOVERY - LVS shellbox-syntaxhighlight eqiad port 4014/tcp - Shellbox SyntaxHighlight- shellbox-syntaxhighlight.svc.eqiad.wmnet IPv4 on shellbox-syntaxhighlight.svc.eqiad.wmnet is OK: HTTP OK: HTTP/1.1 200 OK - 358 bytes in 1.052 second response time https://wikitech.wikimedia.org/wiki/LVS%23Diagnosing_problems

https://grafana.wikimedia.org/d/vcOTDuSnk/syntaxhighlight?orgId=1&from=1632967782148&to=1632970799524 looks like it hit 1400 requests/min.

Change 724869 had a related patch set uploaded (by Legoktm; author: Legoktm):

[operations/deployment-charts@master] Throw more resources at shellbox-syntaxhighlight

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

Change 724869 merged by jenkins-bot:

[operations/deployment-charts@master] Throw more resources at shellbox-syntaxhighlight

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

Things have looked good ever since the expansion.