Smooth out NFS client writeback
Subsystems (2)
PATCH 1/1 Smooth out NFS client writeback
Hi Trond,
The current NFS client can cause a program to stall for long periods of time because it flushes all dirty pages at once. The attached patch addresses this by only writing back the amount requested by the VM layer. It also reduces the # commit requests by waiting for some writeback to complete before issuing a commit. The patch also speeds up writebacks of mmap'ed data by accumulating dirty pages but sending commits earlier and omitting FLUSH_STABLE.
As part of the patch, I reinstated specifying the commit range because I observed a marked speed up when testing on a filesystem mounted from a Solaris 2.10 server.
The patch is against 2.6.12-rc5 w/NFS_ALL.
Thanks,
Shantanu
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
fs/nfs/inode.c +0 -15
@@ -60,7 +60,6 @@static struct inode *nfs_alloc_inode (struct super_block *sb);static void nfs_destroy_inode (struct inode *); -static int nfs_write_inode (struct inode *,int );static void nfs_delete_inode (struct inode *);static void nfs_clear_inode (struct inode *);static void nfs_umount_begin (struct super_block *);
@@ -74,7 +73,6 @@static struct super_operations nfs_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, - .write_inode = nfs_write_inode, .delete_inode = nfs_delete_inode, .statfs = nfs_statfs, .clear_inode = nfs_clear_inode,
@@ -187,18 +185,6 @@return nfs_fileid_to_ino_t (fattr->fileid); } -static int -nfs_write_inode (struct inode *inode,int sync) -{ -int flags = sync ?FLUSH_WAIT :0 ; -int ret; - - ret =nfs_commit_inode (inode, flags); -if (ret <0 ) -return ret; -return 0 ; -} -static void nfs_delete_inode (struct inode * inode) {
@@ -1904,7 +1890,6 @@static struct super_operations nfs4_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, - .write_inode = nfs_write_inode, .delete_inode = nfs_delete_inode, .statfs = nfs_statfs, .clear_inode = nfs4_clear_inode,
fs/nfs/pagelist.c +4 -1
@@ -282,7 +282,8 @@*/ int nfs_scan_lock_dirty (struct nfs_inode *nfsi,struct list_head *dst, -unsigned long idx_start,unsigned int npages) +unsigned long idx_start,unsigned int npages, +unsigned int max) {struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES ];struct nfs_page *req;
@@ -317,6 +318,8 @@ res++; } } +if (max >0 && res >= max) +break ; } out:return res;
fs/nfs/write.c +230 -75
519 lines not on this page · raw message
include/linux/nfs_fs.h +0 -9
@@ -408,15 +408,6 @@* return value!) */ extern int nfs_sync_inode (struct inode *,unsigned long ,unsigned int ,int ); -#if defined(CONFIG_NFS_V3 ) || defined(CONFIG_NFS_V4 ) -extern int nfs_commit_inode (struct inode *,int ); -#else -static inline int -nfs_commit_inode (struct inode *inode,int how) -{ -return 0 ; -} -#endif static inline int nfs_have_writebacks (struct inode *inode)
include/linux/nfs_page.h +1 -1
@@ -61,7 +61,7 @@extern int nfs_scan_lock_dirty (struct nfs_inode *nfsi,struct list_head *dst, -unsigned long idx_start,unsigned int npages); +unsigned long idx_start,unsigned int npages,unsigned int max);extern int nfs_scan_list (struct list_head *,struct list_head *,unsigned long ,unsigned int ); extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
on den 01.06.2005 Klokka 18:38 (-0700) skreiv Shantanu Goel:
Quoted 11 lines
Hi Trond,
The current NFS client can cause a program to stall for long periods of time because it flushes all dirty pages at once. The attached patch addresses this by only writing back the amount requested by the VM layer. It also reduces the # commit requests by waiting for some writeback to complete before issuing a commit. The patch also speeds up writebacks of mmap'ed data by accumulating dirty pages but sending commits earlier and omitting
FLUSH_STABLE.
Hi Shantanu,
Do you have any figures on this subject? I'd very much like to see how this changes the figures for both the throughput and the latency. We should look at both slow and fast networks (say 10Mbit, 100Mbit & 1GigE).
My other question is how it affects stability in the case of low memory situations?
Cheers,
Trond
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Here are some numbers with iozone (avg of 3 runs). The command was run as: iozone -i0 -r4k -s64m -c -t4 I manually booted the client machine with mem=256M. It has 2 Xeon CPU's with hyperthreading enabled. The server is running 2.6.11. The machines are on 100mb ethernet. The filesystem is mounted with tcp,rsize=32768,wsize=32768.
Stock w/Patch parent write 7227 6155 parent rewrite 7068 6973
children write 7826 11659
children rewrite 7083 6974
I also ran iozone in mmap mode with same options as above but specifying -B as well. The machine hung with the stock client so could not complete the test. Here are the numbers with the patched client.
parent write 6350 parent rewrite 4167 children write 9375
children rewrite 4792
I also ran a latency test using the script I'm attaching to this email. The script was invoked as:
write-test.pl 256m
It writes a 256MB and prints the time elapsed for each 5% increment.
Stock:
5(0s)
10(0s)
15(0s)
20(0s)
25(0s)
30(7s)
35(3s)
40(1s)
45(0s)
50(0s)
55(0s)
60(7s)
65(3s)
70(0s)
75(0s)
80(1s)
85(0s)
90(7s)
95(3s)
100(0s)
sync(4s)
Throughput: 7084 KB/s (6 MB/s)
w/Patch:
5(0s)
10(0s)
15(0s)
20(0s)
25(0s)
30(0s)
35(0s)
40(0s)
45(2s)
50(1s)
55(3s)
60(2s)
65(2s)
70(2s)
75(1s)
80(2s)
85(2s)
90(2s)
95(1s)
100(2s)
sync(11s)
Throughput: 7710 KB/s (7 MB/s)
--- Trond Myklebust <[email protected]>
Quoted 29 lines · wrote:
on den 01.06.2005 Klokka 18:38 (-0700) skreiv Shantanu Goel:
Quoted 3 lines
Hi Trond,
The current NFS client can cause a program to
stall
Quoted 1 line
for long periods of time because it flushes all
dirty
Quoted 1 line
pages at once. The attached patch addresses this
by
Quoted 3 lines
only writing back the amount requested by the VM layer. It also reduces the # commit requests by waiting for some writeback to complete before
issuing
Quoted 2 lines
a commit. The patch also speeds up writebacks of mmap'ed data by accumulating dirty pages but
sending
Quoted 1 line
commits earlier and omitting
FLUSH_STABLE.Hi Shantanu,
Do you have any figures on this subject? I'd very much like to see how
this changes the figures for both the throughput and the latency. We
should look at both slow and fast networks (say 10Mbit, 100Mbit &
1GigE).
Quoted 8 lines
My other question is how it affects stability in the case of low memory
situations?Cheers,
Trond
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
on den 01.06.2005 Klokka 20:26 (-0700) skreiv Shantanu Goel:
Quoted 3 lines
Here are some numbers with iozone (avg of 3 runs). The command was run as: iozone -i0 -r4k -s64m -c -t4 I manually booted the client machine with mem=256M.
What happens when you increase the file size to significantly beyond the memory size on a slow network. That is the interesting case. Try, for instance, booting with mem=32m and iozone -s
Quoted 4 lines
I also ran iozone in mmap mode with same options as above but specifying -B as well. The machine hung with the stock client so could not complete the test. Here are the numbers with the patched client.
Where was the machine hanging?
Cheers,
Trond
BTW: how did you determine the values for NFS_WRITE_CLUSTER and NFS_COMMIT_CLUSTER. they appear to be completely arbitrary AFAICS.
Also, have you compared to the latest NFS_ALL kernels? They contain a bunch of extra latency fixes that came from Ingo's RT work.
Finally, please explain _why_ have you removed the FLUSH_STABLE from nfs_writepage()? The reason for it in the existing code is to avoid the extra COMMIT call in situations where we know we are already very low on memory. I don't see anything new in your patches that avoids these low memory situations.
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
--- Trond Myklebust <[email protected]>
Quoted 7 lines · wrote:
What happens when you increase the file size to significantly beyond the
memory size on a slow network. That is the interesting case.
Try, for instance, booting with mem=3D32m and iozone -s=20
=20
I'll run this case and report back.
Quoted 9 lines
Quoted 1 line
I also ran iozone in mmap mode with same options
as
Quoted 2 lines
above but specifying -B as well. The machine hung with the stock client so could not complete the
test.=20
Quoted 1 line
Here are the numbers with the patched client.
=20
Where was the machine hanging?
=20
I didn't have console access due to X. I'll try and get a sysrq-t when I get a chance.
Quoted 5 lines
BTW: how did you determine the values for
NFS_WRITE_CLUSTERandNFS_COMMIT_CLUSTER. they appear to be completely
arbitrary AFAICS.
=20
NFS_WRITE_CLUSTER is a variant of SWAP_CLUSTER_MAX used by kswapd. NFS_COMMIT_CLUSTER was chosen to match balance_dirty_pages() which uses 4MB for throttling a writer.
Quoted 5 lines
Also, have you compared to the latest
NFS_ALLkernels? They contain a
bunch of extra latency fixes that came from Ingo's RT work.
=20
This patch is on top of 2.6.12-rc5 with NFS_ALL for 2.6.12-rc4. The stock numbers I reported are with NFS_ALL. Is there a newer version somewhere?
Quoted 9 lines
Finally, please explain _why_ have you removed the
FLUSH_STABLEfromnfs_writepage()? The reason for it in the existing code is to avoid the
extra COMMIT call in situations where we know we are already very low on
memory. I don't see anything new in your patches that avoids these low
memory situations.
The current FLUSH_STABLE behaviour absolutely shoots our performance on iozone -B compared to Solaris. The low memory situation is avoided because of the congestion check I added in writepage(). If the inode is congested, it redirty's the page and returns. It also issues a commit request if there are at least NFS_WRITE_CLUSTER pages.
=09
=09
__________________________________=20
Do you Yahoo!?=20
Yahoo! Mail - You care about security. So do we.=20
http://promotions.yahoo.com/new_mail
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dclic=
k
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
to den 02.06.2005 Klokka 05:16 (-0700) skreiv Shantanu Goel:
Quoted 5 lines
The low memory situation is avoided because of the congestion check I added in
writepage(). If the inode is congested, it redirty's the page and returns. It also issues a commit request if there are at leastNFS_WRITE_CLUSTERpages.
This sounds very much like what we were doing in the early 2.6 series when we were returning WRITEPAGE_ACTIVATE in order to achieve the same effect. We ended up reverting those patches after learning that systematically redirtying pages in low-memory situations may lead to some _very_ nasty deadlocks.
The above have "works" for ramdisks because they have hard limits on the amount of physical memory they can use in the form of the ramdisk size. NFS OTOH really shouldn't do it, since it has no such limits, and can basically end up eating all of physical memory.
Have you BTW tested the performance of the other changes without this part of the patch? I assume the numbers you presented last week were for the combined changes.
Cheers,
Trond
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Hi Trond,
Attached is the long delayed revised version of the writeback smoothing patch this time against 2.6.12-mm2. I have omitted the commit w/range and mmap writeback from this one. If this one is deemed acceptable for inclusion I'll post the other 2 later. The commit w/range really should be restored as it makes quite a difference against Solaris NFS servers with regular disks. I observed a difference of 2-3 MB/s under sustained writes. It makes no difference with the Linux NFS server since it ignores the range.
I tested this version by reducing memory to 32M but iozone OOM'ed. However, I observed the same behaviour with the unpatched client. If I reduce dirty_ratio to 20 from 40 (the default), iozone completes without a problem on both versions. I noticed the slab cache gets as big as the page cache and the VM fails to take that in account. In summary, the behaviour is at least as good as that of the stock client in this case.
Thanks,
Shantanu
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
fs/nfs/inode.c +0 -15
@@ -58,7 +58,6 @@static struct inode *nfs_alloc_inode (struct super_block *sb);static void nfs_destroy_inode (struct inode *); -static int nfs_write_inode (struct inode *,int );static void nfs_delete_inode (struct inode *);static void nfs_clear_inode (struct inode *);static void nfs_umount_begin (struct super_block *);
@@ -71,7 +70,6 @@static struct super_operations nfs_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, - .write_inode = nfs_write_inode, .delete_inode = nfs_delete_inode, .statfs = nfs_statfs, .clear_inode = nfs_clear_inode,
@@ -129,18 +127,6 @@return nfs_fileid_to_ino_t (fattr->fileid); } -static int -nfs_write_inode (struct inode *inode,int sync) -{ -int flags = sync ?FLUSH_WAIT :0 ; -int ret; - - ret =nfs_commit_inode (inode, flags); -if (ret <0 ) -return ret; -return 0 ; -} -static void nfs_delete_inode (struct inode * inode) {
@@ -1565,7 +1551,6 @@static struct super_operations nfs4_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, - .write_inode = nfs_write_inode, .delete_inode = nfs_delete_inode, .statfs = nfs_statfs, .clear_inode = nfs4_clear_inode,
fs/nfs/pagelist.c +3 -14
@@ -126,19 +126,6 @@ }/** -* nfs_clear_page_writeback - Unlock request and wake up sleepers -*/ -void nfs_clear_page_writeback (struct nfs_page *req) -{ -struct nfs_inode *nfsi =NFS_I (req->wb_context->dentry->d_inode); - -spin_lock (&nfsi->req_lock); -radix_tree_tag_clear (&nfsi->nfs_page_tree, req->wb_index,NFS_PAGE_TAG_WRITEBACK ); -spin_unlock (&nfsi->req_lock); -nfs_unlock_request (req); -} - -/** * nfs_clear_request - Free up all resources allocated to the request * @req: *
@@ -277,7 +264,7 @@*/ int nfs_scan_lock_dirty (struct nfs_inode *nfsi,struct list_head *dst, -unsigned long idx_start,unsigned int npages) +unsigned long idx_start,unsigned int npages,unsigned int max) {struct nfs_page *pgvec[NFS_SCAN_MAXENTRIES ];struct nfs_page *req;
@@ -310,6 +297,8 @@nfs_list_remove_request (req);nfs_list_add_request (req, dst); res++; +if (max && res >= max) + goto out; } } }
fs/nfs/write.c +244 -120
595 lines not on this page · raw message
include/linux/nfs_fs.h +0 -9
@@ -394,15 +394,6 @@* return value!) */ extern int nfs_sync_inode (struct inode *,unsigned long ,unsigned int ,int ); -#if defined(CONFIG_NFS_V3 ) || defined(CONFIG_NFS_V4 ) -extern int nfs_commit_inode (struct inode *,int ); -#else -static inline int -nfs_commit_inode (struct inode *inode,int how) -{ -return 0 ; -} -#endif static inline int nfs_have_writebacks (struct inode *inode)
include/linux/nfs_page.h +1 -2
@@ -62,7 +62,7 @@extern int nfs_scan_lock_dirty (struct nfs_inode *nfsi,struct list_head *dst, -unsigned long idx_start,unsigned int npages); +unsigned long idx_start,unsigned int npages,unsigned int max);extern int nfs_scan_list (struct list_head *,struct list_head *,unsigned long ,unsigned int ); extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
@@ -70,7 +70,6 @@extern int nfs_wait_on_request (struct nfs_page *);extern void nfs_unlock_request (struct nfs_page *req);extern int nfs_set_page_writeback_locked (struct nfs_page *req); -extern void nfs_clear_page_writeback (struct nfs_page *req);/*
Quoted 12 lines · Shantanu Goel
Hi Trond,
Attached is the long delayed revised version of the
writeback smoothing patch this time against
2.6.12-mm2. I have omitted the commit w/range and
mmap writeback from this one. If this one is deemed
acceptable for inclusion I'll post the other 2 later. The commit w/range really should be restored as it makes quite a difference against Solaris NFS servers
with regular disks. I observed a difference of 2-3
MB/s under sustained writes. It makes no difference
with the Linux NFS server since it ignores the range.
On Solaris, at least with UFS as the underlying file system, the COMMIT operations are processed by looking through the entire cached page list or by doing page lookup operations on each individual page. If the entire file is specified, ie. len = 0, then the page list is walked. If a range is specified, then just the pages within the range are looked up.
Specifying the range can result in significantly less CPU overhead on the server. This is why the NFSv3 COMMIT operation has a range which can be specified... :-)
ps
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs