From 981e19b0038f772d17dddcb36ee079b87fdfa297 Mon Sep 17 00:00:00 2001
From: Bron Gondwana <brong@fastmail.fm>
Date: Wed, 24 Dec 2008 23:26:30 +1100
Subject: [PATCH] skiplist tuning

Skiplist tuning

<b>Not a candiate for upstream without additional debate</b>

With random changes to a mailboxes.db file, it could be nearly 100%
random seeks before it recompressed.

A seen file would need to reach 16kb before even considering
re-compressing, with a real data length of just a couple of hundred
bytes.

This patch reduces the limits to:

4kb overhead
120% rather than 200% of current "sorted" size.

It's been running happily on our servers, but hey - tuning is
a black art!  I don't really care too much either way.  Would
prefer a way to force a "checkpoint", since ctl_cyrusdb -c
doesn't actually do it...
---
 lib/cyrusdb_skiplist.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/cyrusdb_skiplist.c b/lib/cyrusdb_skiplist.c
index 90ead62..518adee 100644
--- a/lib/cyrusdb_skiplist.c
+++ b/lib/cyrusdb_skiplist.c
@@ -313,7 +313,7 @@ enum {
     SKIPLIST_VERSION = 1,
     SKIPLIST_VERSION_MINOR = 2,
     SKIPLIST_MAXLEVEL = 20,
-    SKIPLIST_MINREWRITE = 16834 /* don't rewrite logs smaller than this */
+    SKIPLIST_MINREWRITE = 4096 /* don't rewrite logs smaller than this */
 };
 
 #define HEADER_MAGIC ("\241\002\213\015skiplist file\0\0\0")
@@ -1505,7 +1505,7 @@ int mycommit(struct db *db, struct txn *tid)
 
     /* consider checkpointing */
     if (!r && !db->current_txn && 
-              tid->logend > (2 * db->logstart + SKIPLIST_MINREWRITE)) {
+              tid->logend > (12 * db->logstart / 10 + SKIPLIST_MINREWRITE)) {
 	r = mycheckpoint(db, 1);
     }
     
-- 
1.5.6.5

