TDB locking overhead and performance...

James Peach jpeach at samba.org
Sun Apr 23 23:18:53 GMT 2006


On Sun, 2006-04-23 at 13:22 +0100, Daniel J Blueman wrote:
> > > As a test, I changed the opening of the locking.tdb and brlock.tdb
> > > files to use the TDB_INTERNAL flag, avoiding use of the fcntl(F_SETLK)
> > > syscall for locking individual database records. Performance was a lot
> > > snappier, with quite a bit less system time used.
> > >
> > > What is the scope of implementing shared memory TDBs, where locking
> > > could be done simply on structures?
> >
> > How would you implement cross-process locking without
> > any syscalls? Maybe Linux has some fancy stuff here, but for
> > most unixes we need to coordinate the mmap'ed area for the
> > tdbs fcntl locks.
> 
> Locking via a 'volatile int count' in a shared file-backed or
> anonymous mapping, or via sys V shm is what I had in mind.

See tdb/spinlock.[ch] in the Samba source.

> This would be quite clean to implement, but I just can't find any
> user-space atomic operations exported by glibc. There are clever
> tricks to use the kernel ones in /usr/include/asm/atomic.h, but that
> is an ugly hack.
> 
> Any ideas?

Very recent gcc does have atomic op builtins, though I'm not sure how
many platforms they are implemented for:
	http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html


-- 
James Peach | jpeach at samba.org



More information about the samba-technical mailing list