Skip to contentSkip to conversation

Parallelize file operation (like creation, unlink) under large shared directory

LSF/MM TOPIC wangdi 4 participants 6 messages Jan 21, 2012 – Jan 24, 2012 VFS

lore
Share & tools
lore

wangdi

author
#0 lore raw

Single directory performance is a critical in some use cases. For example the multiple application threads might create hundreds of thousands of files in a single directory simultaneously within a short window of time.

Currently, both filename lookup and file system modifying operations (such as create and unlink) are protected with a single lock for the entire directory. It might be useful to remove this lock, so multiple application threads can access the directory simultaneously.

Thanks
WangDi

#1 lore raw
Quoted 5 lines · wangdi

Single directory performance is a critical in some use cases. For example the multiple application threads might create hundreds of thousands of files in a single directory simultaneously within a short window of time.

read NFSD here ;-)

Quoted 5 lines

Currently, both filename lookup and file system modifying operations (such as create and unlink) are protected with a single lock for the entire directory. It might be useful to remove this lock, so multiple application threads can access the directory simultaneously.

I agree about create, unlink, and so on. But don't we have some lockless look up in place since a few Kernels ago?

But yes the topic is very interesting, though I'd suspect its hard to implement.

Quoted 3 lines

Thanks
WangDi

Thanks
Boaz

author
#2 lore raw
Quoted 8 lines · Boaz Harrosh
Quoted 5 lines · wangdi

Single directory performance is a critical in some use cases. For example the multiple application threads might create hundreds of thousands of files in a single directory simultaneously within a short window of time.

read NFSD here ;-)

Quoted 7 lines
Quoted 5 lines

Currently, both filename lookup and file system modifying operations (such as create and unlink) are protected with a single lock for the entire directory. It might be useful to remove this lock, so multiple application threads can access the directory simultaneously.

I agree about create, unlink, and so on. But don't we have some lockless look up in place since a few Kernels ago?

The lockless lookup is only for lookups in the dcache and not in the backing filesystem, which is serialized by i_mutex in the VFS(real_lookup).

Quoted 2 lines

But yes the topic is very interesting, though I'd suspect its hard to implement.

We actually already implemented this for ext4, and we saw a lot performance improvement(at least 30% improvements for open/create in a single directory)for lustre stack, but we want to make this improvement accessible through the VFS. Probably XFS and Btrfs could also benefit from this.

Thanks
WangDi

Quoted 5 lines
Quoted 3 lines

Thanks
WangDi

Thanks
Boaz

maintainer
#3 lore raw
Quoted 2 lines · wangdi

We actually already implemented this for ext4, and we saw a lot performance improvement(at least 30% improvements for open/create in a single directory)for lustre stack, but we want to make this improvement accessible through the VFS. Probably XFS and Btrfs could also benefit from this.

You do realize that i_mutex locking is relied upon for protection of a lot of stuff besides the obvious (i.e. on-disk directory contents)?

I'm not saying that it's hopeless, but it's highly non-trivial; the things like rmdir/mount races, access to ->d_parent/->d_name in a lot of code, etc. need to be taken care of and it is a _lot_ of code review to deal with - just to verify the correctness of such changes.

author
#4 lore raw
Quoted 10 lines · Al Viro
Quoted 2 lines · wangdi

We actually already implemented this for ext4, and we saw a lot performance improvement(at least 30% improvements for open/create in a single directory)for lustre stack, but we want to make this improvement accessible through the VFS. Probably XFS and Btrfs could also benefit from this.

You do realize that i_mutex locking is relied upon for protection of a lot of stuff besides the obvious (i.e. on-disk directory contents)? I'm not saying that it's hopeless, but it's highly non-trivial; the things like rmdir/mount races, access to ->d_parent/->d_name in a lot of code, etc. need to be taken care of and it is a _lot_ of code review to deal with - just to verify the correctness of such changes.

Yes, I agree it is non-trivial change here. What I want to say is that i_mutex lock might be too big in some cases, and it just serializes everything. So it might be useful if we could refine this lock a bit. For example we can define this lock with several modes, (read, write, current read, current write, exclusive etc), and different code can get the lock with different mode as required, which might bring us some concurrency.

Thanks
WangDi

#5 lore raw
Quoted 12 lines · wangdi
Quoted 10 lines · Al Viro
Quoted 2 lines · wangdi

We actually already implemented this for ext4, and we saw a lot performance improvement(at least 30% improvements for open/create in a single directory)for lustre stack, but we want to make this improvement accessible through the VFS. Probably XFS and Btrfs could also benefit from this.

You do realize that i_mutex locking is relied upon for protection of a lot of stuff besides the obvious (i.e. on-disk directory contents)? I'm not saying that it's hopeless, but it's highly non-trivial; the things like rmdir/mount races, access to ->d_parent/->d_name in a lot of code, etc. need to be taken care of and it is a _lot_ of code review to deal with - just to verify the correctness of such changes.

Quoted 7 lines

Yes, I agree it is non-trivial change here. What I want to say is that i_mutex lock might be too big in some cases, and it just serializes everything. So it might be useful if we could refine this lock a bit. For example we can define this lock with several modes, (read, write, current read, current write, exclusive etc), and different code can get the lock with different mode as required, which might bring us some concurrency.

Irix used a read/write lock for the VFS level locking. XFS still has that same locking for it's directory operations. Lookup takes it in read mode, and now XFS has lockless inode cache lookups, too. Hence if we can etch the correct Cthulu Summoning Patterns^W^W^W locking primitives in the VFS, XFS can definitely take advantage of it...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]