dendrite/roomserver/api
Till 5267cc0f54
Optimise getting local members and membership counts (#3150)
The previous version was getting **ALL** membership events (as
`ClientEvents`, so going through `NewEventFromTrustedJSONWithID`) for a
given room.
Now we are querying only locally joined users as `ClientEvents`, which
should **significantly** reduce allocations.

Take for example a large room with 2k membership events, but only 1
local user - avoiding 1999 `NewEventFromTrustedJSONWithID` calls just to
calculate the `roomSize` which we can also query by other means.

This is also getting called for every `OutputRoomEvent` in the userAPI.

Benchmark with 1 local user and 100 remote users.
```
pkg: github.com/matrix-org/dendrite/userapi/consumers
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
                    │   old.txt   │               new.txt               │
                    │   sec/op    │   sec/op     vs base                │
LocalRoomMembers-16   375.9µ ± 7%   327.6µ ± 6%  -12.85% (p=0.000 n=10)

                    │    old.txt    │               new.txt                │
                    │     B/op      │     B/op      vs base                │
LocalRoomMembers-16   79.426Ki ± 0%   8.507Ki ± 0%  -89.29% (p=0.000 n=10)

                    │   old.txt   │              new.txt               │
                    │  allocs/op  │ allocs/op   vs base                │
LocalRoomMembers-16   1015.0 ± 0%   277.0 ± 0%  -72.71% (p=0.000 n=10)
```
2023-07-13 14:19:08 +02:00
..
alias.go Use SenderID Type (#3105) 2023-06-07 17:14:35 +00:00
alias_test.go Fix lint errors 2022-03-24 10:03:22 +00:00
api.go Optimise getting local members and membership counts (#3150) 2023-07-13 14:19:08 +02:00
input.go Remove gmsl.HeaderedEvent (#3068) 2023-04-27 12:54:20 +01:00
output.go Cleanup remaining statekey usage for senderIDs (#3106) 2023-06-12 11:19:25 +00:00
perform.go Add pseudoID compatibility to Invites (#3126) 2023-07-06 15:15:24 +00:00
query.go Add MXIDMapping for pseudoID rooms (#3112) 2023-06-28 20:29:49 +02:00
wrapper.go Move json errors over to gmsl (#3080) 2023-05-09 22:46:49 +00:00