Open jonasfj opened 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..
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.
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...
Ah gross, I remember choking over this before. I'll leave this open for now and come back after a few sleeps.
Instrumenting
store.Fetch
I saw that leaps calledstore.Fetch
a lot. Fixing theflush_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.