element-hq / element-hq/element-web
let the debounceTime or a delayTimer be easily configureable for admins when searching for people in element
- Dominant language
- TypeScript
- Stars
- 13.5k
- Forks
- 2.8k
- PR merge metrics
- PR metrics pending
Description
### Your use case
#### What would you like to do?
It would be nice to have an easy setting or variable to either control the debounceTimer (default: 150ms) or to set a delayTimer, after which the search for users fires off in element-web.
#### Why would you like to do it?
We have 50k users at our homeserver, so searching for names can give back a lot of entries. When I am typing the name (e.g. "surname"), I see the search firing off in the backend (ma1sd) before I even type the first letter (`org.apache.mina.filter.codec.ProtocolEncoderException: org.apache.directory.api.ldap.codec.api.MessageEncoderException: ERR_04058 Cannot have a null initial, any and final substring`) and then searches for every single character added:
Threepid: found 2654 match(es) for 's'
Threepid: found 1199 match(es) for 'su'
Threepid: found 395 match(es) for 'sur'
...
Threepid: found 5 match(es) for 'surname'
Since my backend is configured to be also searchable by LDAP attributes: display name, surname and givenname and not just the mail/3PID, it does the same thing for `io.kamax.mxisd.backend.sql.generic.GenericSqlDirectoryProvider - Searching users by display name using 'su'`.
This becomes a problem when typing a more famous name;
`Suppressed 44423 messages from matrix-ma1sd.service` and rateLimiting starts to kick in resulting in a chunky, slow or at worst not working search. For example, we have many users beginning with "k...", so typing kath results in:
```
INFO io.kamax.mxisd.directory.DirectoryManager - Threepid: found 11103 match(es) for 'k'
INFO io.kamax.mxisd.directory.DirectoryManager - Total matches: 11524 - limited? false
INFO io.kamax.mxisd.directory.DirectoryManager - Performing search for 'ka'
INFO io.kamax.mxisd.directory.DirectoryManager - Threepid: found 9590 match(es) for 'ka'
INFO io.kamax.mxisd.directory.DirectoryManager - Total matches: 9914 - limited? false
...etc
```
When the usersearch finally gets to the relevant part (surname and givenname typed out to clearly identify some users) it already rate-limited so hard, that it either it returns a result way to late or not at all. Sometimes it does the above, but in a weird (even reverse) order, which I assume, happens because of some rateLimiting somewhere
I already tried optimizing my search with ma1sd by enabling hashmaps, which increases performance but the search in element still fires off at almost every single typed character. I can imagine a lot of unnecessary load on my server when just a percent of my users start using the search
#### How would you like to achieve it?
Allow for an easy configuration for the [debounceTime](https://github.com/matrix-org/matrix-react-sdk/blob/cbb34d8ac7b3ef7529e3e60bd5b76f51fec89748/src/components/views/dialogs/InviteDialog.tsx#L968), which is set at 150ms.
Or (even better) just let the search only fire off, when pressing enter or clicking the search button
### Have you considered any alternatives?
I tried a lot of settings in my ma1sd backend to limit it as much as possible but I cannot restrict the searchable attributes anymore than to email, surname and givenname. I tried hashmaps for better performance but that didnt help much
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.