summaryrefslogtreecommitdiffstats
path: root/lib/tdb/common/tdb.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-03-18 08:04:42 +0100
committerMichael Adam <obnox@samba.org>2014-03-18 13:42:10 +0100
commit3034a5a62b8eaac7bdc52bfb7af1beb29e888b34 (patch)
treea45c3019d6e2d34f898332bc623b4a5d38602266 /lib/tdb/common/tdb.c
parent1461362e936e5beebeaae1555cf96f6731287c35 (diff)
downloadsamba-3034a5a62b8eaac7bdc52bfb7af1beb29e888b34.tar.gz
samba-3034a5a62b8eaac7bdc52bfb7af1beb29e888b34.tar.xz
samba-3034a5a62b8eaac7bdc52bfb7af1beb29e888b34.zip
tdb: Reduce freelist contention
In a metadata-intensive benchmark we have seen the locking.tdb freelist to be one of the central contention points. This patch removes most of the contention on the freelist. Ages ago we already reduced freelist contention by using the even much older DEAD records: If TDB_VOLATILE is set, don't directly put deleted records on the freelist, but just mark a few of them just as DEAD. The next new record can them re-use that space without consulting the freelist. This patch builds upon the DEAD records: If we need space and the freelist is busy, instead of doing a blocking wait on the freelist, start looking into other chains for DEAD records and steal them from there. This way every hash chain becomes a small freelist. Just wander around the hash chains as long as the freelist is still busy. With this patch and the tdb mutex patch (following hopefully some time soon) you can see a heavily busy clustered smbd run without locking.tdb futex syscalls. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/tdb/common/tdb.c')
-rw-r--r--lib/tdb/common/tdb.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index a7111dea96..ba1c98edbe 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -550,26 +550,8 @@ static int _tdb_store(struct tdb_context *tdb, TDB_DATA key,
}
}
- /*
- * We have to allocate some space from the freelist, so this means we
- * have to lock it. Use the chance to purge all the DEAD records from
- * the hash chain under the freelist lock.
- */
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
- goto fail;
- }
-
- if ((tdb->max_dead_records != 0)
- && (tdb_purge_dead(tdb, hash) == -1)) {
- tdb_unlock(tdb, -1, F_WRLCK);
- goto fail;
- }
-
/* we have to allocate some space */
- rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec);
-
- tdb_unlock(tdb, -1, F_WRLCK);
+ rec_ptr = tdb_allocate(tdb, hash, key.dsize + dbuf.dsize, &rec);
if (rec_ptr == 0) {
goto fail;