On Sun, Mar 24, 2013 at 11:49:23PM +0000, Ignas Anikevičius wrote:
> Hello, 
> 
> On 24/03/13 03:34:33 +0100, Sebastian Ramacher wrote:
> > ...
> >
> > The code to destroy the cairo surfaces periodically is not optimal, but
> > if it all, we should fix this portion of the code. Maybe a timing-based
> > solution is not a good idea and there are better ways to approach this,
> > but I really don't want to ruin the above use case again.
> > 
> > Ideas and patches to improve the page reclaiming code are very welcome.
> >
> > ...
> 
> I was thinking about this and thought, that maybe a combination of two
> approaches could be possible. I'll try to depict what I have in mind:
> 
>     - Load zathura and render the pages (i.e. keep them in memory),
>       which are visible. 
> 
>     - When scrolling, remember all the pages seen in the last, say, 5
>       minutes.
> 
>     - If we scroll through many pages, then it means that we are not
>       interested in viewing all of the pages, which we have seen in the
>       last 5 minutes. Then remember only the last 10 pages.
> 
> So in essence, what I propose, is to keep a page buffer which would
> remember all pages from last 5 minutes or last 10 pages whichever is
> smaller. Of course the quantities here are taken only for illustrative
> purposes and I have no idea whether they make sense or not.

As far as I understand from this, you're talking about a cache of configurable 
size (in number of pages), that are invalidated using a LRU algorithm. If 
that's the case, then I like your idea, and think that it would be effective 
here.

> Also, I remember, that I hit a mem-leak recently when working on a
> poster made with LaTeX. I was recompiling the same page over and over
> again with LaTeX and I the memory consumption went very high. I was
> wondering if this is because zathura was remembering the pages from the
> previous versions of the recompiled document. Maybe zathura should free
> memory on document reloads?

Yes, this is an actual bug that is reported at http://bugs.pwmt.org/issue274 
and it should be fixed. Maybe you're the one who reported it!

> Also, I thought a while ago, that zathura's rendering experience could
> be even further enhanced by caching the pages, which have not been seen
> yet. For example at one moment we see a row of pages and zathura caches
> the row above and below the one we currently view. Then if we scroll in
> either direction, the page is already rendered, which might be visually
> more pleasing than waiting for a large page to come up. Of course, this
> should be implemented in such a way, that we do not recache the pages,
> which are already among the ones which have been looked at recently.

That's exactly what I've just been thinking about, simply a sliding window of a 
configurable number of rows centered at the current visible one and moving with 
us as we scroll around.

Combined with the above caching, then pages outside of this window shouldn't be 
freed unless they 1) aren't in the cache, or 2) are in the cache, but need to 
be invalidated in order to make room for the currently visible ones if they 
aren't already in the cache.

> Let me know if I made the explanation clear enough and if something
> similar would be desired in zathura.

I think we're yet to see what Sebastian (and maybe others) think of this. I was 
just expressing my opinion.


                
        Marwan
_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to