Problem
Current syncing of indexer state to client does not scale.
Getting data from the indexer is quick and no problem. It is the updating of the entities store that takes long (currently about 10 seconds) and blocks the UI in the process, so we can't show any progress indication either.
We are currently getting everything from the indexer, syncing it all to the entitites store, then filter it down to only the machines etc... that are in the player's own pod.
This problem will get worse and worse very quickly.
Current method
We set up listeners for all tables we are interested in here:
|
for (const componentKey of mudLayer.tableKeys) { |
The svelte store is then update on each update from the chain:
|
entities.update(value => { |
So far this works OK once you are in the game – but not on load when you get 3000+ updates quickly.
Possible solution 1
Filter what we sync from the indexer.
We need:
- All orders, recipes, offers, materials.
- gameConfig
- all players names
- only machines, tanks that are in the player's pod (same
carriedBy component value)
Can we filter by the carriedBy value?
How do we know the id of the players pod before syncing?
Possible solution 2
Get state from indexer.
Set entities in one go.
Avoiding the many calls to entities.update.
Possible solution 3
Move updating the entities store to a webworker.
Probably not possible.
Problem
Current syncing of indexer state to client does not scale.
Getting data from the indexer is quick and no problem. It is the updating of the
entitiesstore that takes long (currently about 10 seconds) and blocks the UI in the process, so we can't show any progress indication either.We are currently getting everything from the indexer, syncing it all to the
entititesstore, then filter it down to only the machines etc... that are in the player's own pod.This problem will get worse and worse very quickly.
Current method
We set up listeners for all tables we are interested in here:
this-cursed-machine/packages/client/src/svelte/initNetwork.ts
Line 25 in 016d5f9
The svelte store is then update on each update from the chain:
this-cursed-machine/packages/client/src/svelte/modules/systems/createComponentSystem.ts
Line 20 in 016d5f9
So far this works OK once you are in the game – but not on load when you get 3000+ updates quickly.
Possible solution 1
Filter what we sync from the indexer.
We need:
carriedBycomponent value)Can we filter by the
carriedByvalue?How do we know the id of the players pod before syncing?
Possible solution 2
Get state from indexer.
Set
entitiesin one go.Avoiding the many calls to
entities.update.Possible solution 3
Move updating the
entitiesstore to a webworker.Probably not possible.