The current implementation of pushing notifications into the job queue happens at the per-event (before users are decided) level. IIRC this was done because of concerns that some notification types might notify several hundred users.
We should move the job queue work up to a much higher level, all the way to generateEventsForRevision(), where the only data that needs to be passed into the job queue is the revision id. We should do this because diffing, parsing, and deciding what happens takes around 1/3 of a second on every single wiki edit.
As a temporary solution, aaron has submitted and I have merged https://gerrit.wikimedia.org/r/#/c/211764 which puts this into DeferredUpdates. Another incoming patch will make the DeferredUpdates run in the same process but after the connection to the user has been closed.