summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-06-01 13:13:07 +1000
committerAndrew Tridgell <tridge@samba.org>2009-06-01 13:13:07 +1000
commita6cc04a20089e8fbcce138c271961c37ddcd6c34 (patch)
treee7601b7971f3dd9bdca53cf614e28c8f96c32b04
parenta386173fa1c7c5bcc11ea9260d84b6c52c154b3d (diff)
downloadsamba-a6cc04a20089e8fbcce138c271961c37ddcd6c34.tar.gz
samba-a6cc04a20089e8fbcce138c271961c37ddcd6c34.tar.bz2
samba-a6cc04a20089e8fbcce138c271961c37ddcd6c34.zip
overallocate all records by 25%
This greatly reduces the fragmentation of databases where records tend to grow slowly by a small amount each time. The case where this is most seen is the ldb index records. Adding this overallocation reduced the size of the resulting database by more than 20x when running a test that adds 10k users.
-rw-r--r--lib/tdb/common/freelist.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 2f2a4c379b..3bc3965141 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -284,6 +284,9 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_st
if (tdb_lock(tdb, -1, F_WRLCK) == -1)
return 0;
+ /* over-allocate to reduce fragmentation */
+ length *= 1.25;
+
/* Extra bytes required for tailer */
length += sizeof(tdb_off_t);
length = TDB_ALIGN(length, TDB_ALIGNMENT);