Page MenuHomePhabricator

Timeouts when highlighting source with very long lines using pygmentize
Closed, DuplicatePublic

Description

pygmentize is really slow and expensive for large source but especially for long lines.

We had cases where users pasted large (almost 1MB) JSON one-liner in Paste application and pygmentize caused not only that particular paste page to display nginx "504 Gateway Time-out" error but also for Paste application home page rendering Paste application unaccessible for all users.

Since pages get killed and fail to cache the result Paste application is unaccessible until someone goes directly to paste edit page (../paste/edit/<id>) and changes language to "Plain Text".

Steps to reproduce:

  1. Have Pygments installed and enabled.
  2. Open PasteCreate Paste.
  3. Paste large JSON oneliner (e.g. ~1MB).
  4. Select Language: JSON (or JavaScript).
  5. Click Save.

Expected result:

  • Paste is saved and paste view page opens.

Actual result:

  • Paste is saved but pygmentize process causes view page to timeout.

I can assume this problem is not local to Paste application but anywhere where pygmentize source highlighting is involved.

I'll try to post a diff for this myself but any fix in upstream would be appreciated.

Event Timeline

gd updated the task description. (Show Details)
gd added a project: Paste.
gd added a subscriber: gd.

I'm not sure this is related to "T9415: PhabricatorApplicationTransactionPublishWorker requires unreasonable amount of memory for large numbers of mail recipients?".

Anyway this task can be closed in favour of "T9587: Detect old Pygments versions and encourage an upgrade".

That was just some random demo user clicking buttons. I'll merge 'em.