summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/tdb/common
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-07-29 14:51:34 +0930
committerRusty Russell <rusty@rustcorp.com.au>2009-08-04 16:43:31 +0930
commit825391de1d0a26d58e20caff7f049519302d51a9 (patch)
treec597dc30565cc3fc9165801e7ff570062f868b05 /ctdb/lib/tdb/common
parent94ee0cbe3a568ae3221237df5080adad07577004 (diff)
downloadsamba-825391de1d0a26d58e20caff7f049519302d51a9.tar.gz
samba-825391de1d0a26d58e20caff7f049519302d51a9.tar.xz
samba-825391de1d0a26d58e20caff7f049519302d51a9.zip
Port from SAMBA tdb: commit a6cc04a20089e8fbcce138c271961c37ddcd6c34 Author: Andrew Tridgell <tridge@samba.org> Date: Mon Jun 1 13:13:07 2009 +1000
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. (This used to be ctdb commit e72974e5cefabc7035399d16633f727f868caa61)
Diffstat (limited to 'ctdb/lib/tdb/common')
-rw-r--r--ctdb/lib/tdb/common/freelist.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/common/freelist.c b/ctdb/lib/tdb/common/freelist.c
index 2f2a4c379b0..3bc3965141b 100644
--- a/ctdb/lib/tdb/common/freelist.c
+++ b/ctdb/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);