Skip to content

mwapi: Combine compatible requests (unstable)

legoktm requested to merge combine into master

To improve concurrency of API requests, we attempt to combine GET requests when possible. This behavior is only enabled for a narrow subset of cases where we're confident we can split the request properly and is futher behind a "unstable-combining" feature flag. For now we're focusing on identical action=query requests where only the titles= parameter differs.

Request parameters are examined to see if they're compatible, if so, they're inserted into an IndexMap (for FIFO behavior) keyed by parameters, minus the title. A oneshot channel is created to communicate the response back to the get() function.

A background thread polls map to see if anything new has been added, if so, pops it off and executes the request. Any error is cloned and passed back over the channel. If successful, the response is split up by page and passed back.

The combine example demonstrates and provides a simple test case of how requests are combined under different conditions.

There's a significant amount of work left to do here, but once merged behind an unstable feature flag, it can be iterated on in-tree. Stuff like continuation doesn't work at all yet. It's also unclear whether this will be opt-in for callers or transparently enabled like the current implementation.

Credit to Lucas Werkmeister and his m3api project[1] for coming up with this idea.

[1] https://github.com/lucaswerkmeister/m3api

Fixes #51 (closed).

Merge request reports

Loading