Just before the first fetch counter overflows, right shift all counters by 1. 
This does not change the purge order, keeps the counters in limits and happens 
infrequently (depending on the size of the counter).

-----Ursprüngliche Nachricht-----
Von: Gabriel Corneanu [mailto:gabrielcorne...@gmail.com]
Gesendet: Montag, 25. Februar 2013 12:25
An: sqlite-users@sqlite.org
Betreff: [sqlite] experimental (better?) usage based sqlite cache

Following a few other discussions, I had the feeling that sqlite should benefit 
from a cache which discards cached pages in a least frequently used order.
It generally means, index pages, often used data pages, etc, should be 
preferred (meaning kept in memory) compared to some infrequent used pages.
This helps me where I have big files which are mostly written once, but I also 
have some small tables with summaries; these should be better cached, the same 
for indices.

I first implemented a custom cache in Delphi (Pascal) using some high level 
(generic) containers (hash for keys,  heap for usage data); there is a 
significant overhead due to the classes I used and maybe also compiler 
differences.
My own usage shows some visible improvements, therefore I took some time to 
implement it directly in core (pcache1).

I would like to ask anyone who sees this interesting to try and give some 
feedback about benefits (if at all :)).
Feedback / results / benchmarks are welcome.

If it is useful, I would be happy to contribute it.
The diff is done against 3.7.15.2 ; I'm not sure if it makes it to the list, so 
here is the diff text:
http://pastebin.com/RrzqWjWv

Technical details:
- each page has a fetch counter
- the LRU list is changed to a heap, arranged according to this counter
- when discarding pages, the page with the minimum fetch counter is selected 
Apart from the heap operations, the other changes are quite straightforward.

I run some tests to check for errors, maybe someone can check if the 
initialization is done in proper place (especially for shared cache group).
There is an important catch; the fetch counter overflow. I don't have yet a 
definitive idea how/when to limit or to correct it.
So this problem is currently postponed until the tests show actual benefit / 
interest.

Regards,
Gabriel





--------------------------------------------------------------------------
 Gunter Hick
Software Engineer
Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna, Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then delete this message from 
your system. Please do not copy it or use it for any purposes, or disclose its 
contents to any person as to do so could be a breach of confidence. Thank you 
for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to