tdb: Reduce freelist contention
commit3034a5a62b8eaac7bdc52bfb7af1beb29e888b34
authorVolker Lendecke <vl@samba.org>
Tue, 18 Mar 2014 07:04:42 +0000 (18 08:04 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 18 Mar 2014 12:42:10 +0000 (18 13:42 +0100)
treea45c3019d6e2d34f898332bc623b4a5d38602266
parent1461362e936e5beebeaae1555cf96f6731287c35
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>
lib/tdb/common/freelist.c
lib/tdb/common/tdb.c
lib/tdb/common/tdb_private.h