Jeffail / leaps

A pair programming service using operational transforms
MIT License
753 stars 55 forks source link

leaps loads documents twice (on first load) #5

Open jonasfj opened 9 years ago

jonasfj commented 9 years ago

Instrumenting store.Fetch I saw that leaps called store.Fetch a lot. Fixing the flush_period_ms to 60s helped a lot. I guess if you're using the file system 500ms might be sane (for a few files), but anything else we're probably better off with a much higher default.

Anyways, whenever a document is opened for the first client, not the second client, it's fetched twice. I assume the leaps doesn't keep active documents in memory, which is why it does fetch prior to storing anything. I like that, very efficient.

Perhaps I should do a pull-through storage engine that caches on disk, and does a real fetch if the file isn't on disk.. It could be done as a wrapper to any storage engines.

jonasfj commented 9 years ago

Also, leaps seems to fetch the document every flush_period_ms regardless of whether or not there is any changes to the document.

This is a problem, if we have a lot of documents open. Afaik most people keep a lot of idle tabs around..

Jeffail commented 9 years ago

From scanning the code I can't see straight away where this is happening but there's certainly no reason for it. I'm planning on looking into this next time I'm free but if anyone works it out feel free to send a pull request.

jonasfj commented 9 years ago

I suspect it's NewBinder followed by Subcribe both of which does a flush(). Since we don't keep the document in memory, I'm not sure how to fix this...

Maybe NewBinder could return the Document and subscribe could optionally take a Document parameter... But it's not pretty... So maybe not... I think fixing the mutex is more important...

Jeffail commented 9 years ago

Ah gross, I remember choking over this before. I'll leave this open for now and come back after a few sleeps.