Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

we should optimise rest endpoint dispatch #5118

Open
richvdh opened this issue May 1, 2019 · 3 comments
Open

we should optimise rest endpoint dispatch #5118

richvdh opened this issue May 1, 2019 · 3 comments
Labels
T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@richvdh
Copy link
Member

richvdh commented May 1, 2019

every incoming GET request gets compared against a list of 227 regexps, many of which are redundant since they duplicate each endpoint onto the various places the client API lives. This is surely an unnecessary overhead.

@erikjohnston
Copy link
Member

erikjohnston commented May 2, 2019

Something like https://github.com/nitely/kua would probably work, though its py3 only.

@richvdh
Copy link
Member Author

richvdh commented May 2, 2019

possibly, though I'm not sure how it would tie into twisted.

I was mostly just imagining that it would be a good start to say: for the ClientRestResource which is mounted at /_matrix/client/r0, only register regexes which will actually match that prefix, rather than all of the /_matrix/client/api/v1 etc regexes.

@neilisfragile neilisfragile added z-p2 (Deprecated Label) A-Performance Performance, both client-facing and admin-facing labels May 7, 2019
richvdh added a commit that referenced this issue Feb 18, 2020
we have hundreds of path_regexes (see #5118), so let's not convert the same
bytes to str for each of them.
richvdh added a commit that referenced this issue Feb 19, 2020
we have hundreds of path_regexes (see #5118), so let's not convert the same
bytes to str for each of them.
@clokep
Copy link
Member

clokep commented Nov 29, 2021

every incoming GET request gets compared against a list of 227 regexps

I was a bit curious how this compares to current day:

Method Endpoints
GET 232
PUT 129
POST 169
DELETE 45

I was pretty easily able to reduce this quite a bit by messing with the client_patterns to create a single regular expression instead of multiple patterns. I'm not sure if that's a worthwhile optimization or if we need an entire new strategy. Anyway the results were:

Method Endpoints
GET 80
PUT 39
POST 66
DELETE 15

(These were for the /_matrix/client endpoints using the demo server. so exact endpoints could vary a bit based on configuration.)

@H-Shay H-Shay added T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. and removed z-p2 (Deprecated Label) A-Performance Performance, both client-facing and admin-facing labels Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

No branches or pull requests

5 participants