TryQuiet / quiet

A private, p2p alternative to Slack and Discord built on Tor & IPFS
https://www.tryquiet.org
GNU General Public License v3.0
1.98k stars 87 forks source link

[DRAFT] Given pre-fetched OrbitDB entries, can Quiet iOS display new messages in < 1 second? #2070

Open holmesworcester opened 1 year ago

holmesworcester commented 1 year ago

Our product goal is that a user can open Quiet and see all important messages in less than 1 second.

Assuming we have already fetched recent messages from a relay server and they are on our device (a safe assumption since many apps including Signal work this way) can Quiet iOS display them to the user in less than 1 second after coming back to the foreground?

Here are some cases we care about a lot:

  1. Easy case: Fresh community, 1 new message
  2. Joining user: Fresh community, 1000 new messages
  3. New message received: 20 channels, 1000 messages per channel, 1 new message
  4. Returning user: 20 channels, 1000 messages per channel, 100 new messages

If not, how slow is it? What are the bottlenecks?

Fetched data can be in whatever form is most convenient: OrbitDB entries, IPFS blocks, CAR files, whatever.

If OrbitDB needs several seconds to get started, we can also use another way of displaying new messages to the user immediately, while we wait for OrbitDB.

leblowl commented 1 year ago

Makes sense to me!

holmesworcester commented 11 months ago

@leblowl does this updated draft make sense?

holmesworcester commented 11 months ago

Notes:

  1. Try to get the data injected directly into OrbitDB. Can we do this, how hard is it?
  2. Is there a way to insert message JSON into the frontend, and then handle syncing once we're connected to the network? 2.1. We could blend messages using timestamps and de-dupe with ID. Messages would need to be validated at least as well as we are now. 2.2. If the way we're inserting data gets interrupted, the application could become unusable.
holmesworcester commented 11 months ago

Today Wiktor and Lucas convinced me that #2069 is a more straightforward and direct research question, even if we are ultimately interested in relays more than always-on libp2p/orbitdb nodes. Moving to backlog.

leblowl commented 10 months ago

I was able to add entries directly to OrbitDB: https://github.com/TryQuiet/quiet/pull/2190 This is immediate, but how quickly the frontend connects to the backend and actually displays messages after resume seems to be variable. Sometimes its quite quick but other times it looks like it takes up to around 7 seconds.