Dear experts,

I have a question about the following cache related functions:

   - sqlite3_config(SQLITE_CONFIG_PAGECACHE, B, S, P)
   - sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, C, H, 0)
   - sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, C, H, 0)
   - sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, C, H, 0)

I preallocate an 8 byte aligned memory block of 4096 MB at start-up to use
as page cache.  My page size is 1024 bytes.  According to the documentation,
the page header should be 20 to 40 bytes.  If I assume a cache page header
size of 40 for a total of 1064 bytes, the sqlite3_status() call
S*_PAGECACHE_USED returns 0 while S*_PAGECACHE_OVERFLOW returns a growing
size.  This seems to indicate that the preallocated buffer is not actually
being used by the application, presumably because the page size is too
small.

Looking at the output of S*_PAGECACHE_SIZE, the reported page size is 1272.
If I set the page size to a size larger than this value (I used 1300),
S*_PAGECACHE_OVERFLOW is now 0, while S*_PAGECACHE_USED shows a steadily
growing size.  This is what I expect to indicate that the preallocated
buffer is now being used successfully.

Now as the cache usage increases, I find that it finally caps at 3226.381 MB
(of the total 4096 MB) before the overflow size starts to increase.  At an
initial page size of 1300, the 4096 MB gives 3,303,821 pages.  So, dividing
the used 3226.381 MB by the number of pages, gives 1024 bytes per page.

Is it therefore correct to assume that:

   1. The page cache header size is actually 248 bytes, and not 20 or 40 as
   stated in the documentation, and
   2. The size reported by S*_PAGECACHE_SIZE reports only the size used to
   store actual data, excluding the headers?

If that is correct, it looks like the page cache header is about 25% the
size of the actual data page, which becomes rather expensive as the cache
size increases.

Any comments or feedback will be much appreciated.

Best regards,
Jaco
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to