latitudegames / AIDungeon

Infinite adventures await!
http://www.aidungeon.io/
MIT License
3.2k stars 552 forks source link

[Q/A] Why does the subscriptions websocket returns the entire story text every time? Why not just the diff? #260

Open bironran opened 4 years ago

bironran commented 4 years ago

🤓 Question

I was playing the same story for a while and it got big. Over 8k lines and 400kb. My last inputs and remember are sane size (remember is below 2kb). I was starting to get plagued with "AI is busy" messages so I decided to debug.

I found out that subscription websocket (wss://api.aidungeon.io/subscriptions) returns the entire story after every command and during every KA. In my case, over 1MB of text send every 10 seconds (for KA) and after every action. No wonder I was getting timeouts.

Why was it planned this way, especially for single player adventures? Why not return just the modified text? Alter / revert commands work on the history anyway, so they apply locally after an ack from the server. Additions are easy and the client and server can verify integrity using a checksum after applying the last command then request the entire text on failure.

aawalton commented 4 years ago

We'll likely update the subscription to send a diff at some point. Right now the game is really in an alpha phase, so we're prioritizing speed of iteration and modification over performance. As the game itself stabilizes, performance will increase in priority.