Page MenuHomePhabricator

Push notifications take significant amount of time
Open, Needs TriagePublic

Description

Hi, while running a script calling action=growthsetmentor a lot, I noticed that it's way less performing than I'd expect it to (it should only do permission checks, a write DB query, and sending an echo notification). However, I noticed that the endpoint takes more than expected (sometimes, over a second), and filled T291212: ChangeMentor sometimes takes over a second per change to investigate.

Per https://performance.wikimedia.org/xhgui/run/view?id=614386f2f09ba49ec8ee85e8, MultiHttpClient::runMultiCurl is what takes the most time. Since nothing in ChangeMentor uses HTTP requests, I tried to wrap ChangeMentor::notify (which fires an echo notification) with a DeferredUpdate, and noticed it speeds things up significantly (down to 60ms per API call).

It appears that Echo indeed uses requests in push notifications:

urbanecm@notebook  ~/unsynced/gerrit/mediawiki/extensions/Echo
$ git grep Http
ServiceWiring.php:              $httpRequestFactory = $services->getHttpRequestFactory();
includes/ForeignWikiRequest.php:                $http = MediaWikiServices::getInstance()->getHttpRequestFactory()->createMultiClient();
includes/Push/NotificationServiceClient.php:use MediaWiki\Http\HttpRequestFactory;
includes/Push/NotificationServiceClient.php:use MWHttpRequest;
includes/Push/NotificationServiceClient.php:    /** @var HttpRequestFactory */
includes/Push/NotificationServiceClient.php:     * @param HttpRequestFactory $httpRequestFactory
includes/Push/NotificationServiceClient.php:    public function __construct( HttpRequestFactory $httpRequestFactory, string $endpointBase ) {
includes/Push/NotificationServiceClient.php:     * Construct a MWHttpRequest object based on the subscription and payload.
includes/Push/NotificationServiceClient.php:     * @return MWHttpRequest
includes/Push/NotificationServiceClient.php:    private function constructRequest( string $provider, array $payload ): MWHttpRequest {
tests/phpunit/integration/Push/NotificationServiceClientTest.php:       use MockHttpTrait;
tests/phpunit/integration/Push/NotificationServiceClientTest.php:               $this->installMockHttp( 'hi' );
tests/phpunit/integration/Push/NotificationServiceClientTest.php:               $this->assertInstanceOf( MWHttpRequest::class, $request );
tests/phpunit/revision_txt/138274875.txt:::::Irgendwo kam ein <code>forceHttps</code>-Cookie her, jetzt ist es weg. Es fallen immer noch viele Dinge beim reinen Überfliegen auf:
tests/phpunit/revision_txt/138275105.txt:::::Irgendwo kam ein <code>forceHttps</code>-Cookie her, jetzt ist es weg. Es fallen immer noch viele Dinge beim reinen Überfliegen auf:
urbanecm@notebook  ~/unsynced/gerrit/mediawiki/extensions/Echo
$

Can push notifications be made more faster? To me, as a developer using Echo's interface to fire notifications, it is unexpected that it will take this long -- I'd expect notification to be nearly-instant.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript