element-hq / element-hq/element-web
Dispatcher v2
- Dominant language
- TypeScript
- Stars
- 13.5k
- Forks
- 2.8k
- PR merge metrics
- PR metrics pending
Description
Working theory:

(not to scale)
We can likely improve app performance by simply waking up less components with the global dispatcher. The diagram above is one possible solution, where there are core dispatchers (to avoid waking each other up with noise) and "feeder" dispatchers which are relevant to a particular entity (room, user, model, etc). Those feeder dispatchers would subscribe to specific details from the more coarse dispatchers and filter down accordingly, then filter down again before activating downstream listeners.
As a performance baseline, this is what a random snapshot of activity on my main account (develop, chrome) looks like:

The first few spikes are room switches (with Spaces enabled), then we move into sending messages, browsing rooms, and handling stress tests in megolm-test.
The metrics to beat are (if we assume that the performance issues are in fact because of the dispatcher):
* 250-550ms for room switches
* 430-770ms for room switches over spaces
* A feeling of better performance when using the app (not statistically measurable)
Contributor guide
Assessment
This issue has not been assessed yet.