Skip to contentSkip to conversation

Add write throttling to NFS client

PATCH [email protected] 2 participants 6 messages Mar 1, 2004 – Mar 2, 2004 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

På må , 01/03/2004 klokka 00:14, skreiv Shantanu Goel:

Quoted 10 lines

I did not make that assumption. It does not appear to
be a problem in practice. I ran 4 dd's each writing
256MB in parallel on a machine with 2 CPUs and 64MB memory and it chugged along fine and still allowed other NFS activity on the same mount point. However, I believe this reflects the way the NFS layer is implemented (most request ARE submitted by the writing process except in the case of less than a page worth of writes). However, if that were to ever change, your argument will probably be valid.

Sigh... See the patch linux-2.6.3-02-strategy.dif on the usual patch site. People are asking that we cache more than is currently done in order to allow for better random write performance.

Quoted 5 lines
Quoted 4 lines

Yes, or alternatively, just give the tasks a numeric priority. That's all
we do for real tasks after all...

Quoted 13 lines

Just assigning a priority to requests will not fix the issue. The whole reason I started looking at this was heavy writing to a single inode blocks out all other async write activity. To give a concrete example. Start a dd in the background and then start Mozilla. Even if you give priority to sync requests, Mozilla will hang when it writes its cache files because to the RPC layer, one async write will look the same as the next. The RPC layer must segregate tasks based on some criteria. I chose to use the process id which seems to work pretty well in practice with the current implementation of NFS. So I see no way around batching tasks based on either a cookie or process id.

Huh? Just have the asynchronous tasks sit in a different priority bucket to the synchronous ones and schedule, say 4 asynchronous tasks for every 1 synchronous one. Why would this be so difficult?

Cheers,
Trond

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 2 lines · Shantanu Goel

It won't fix the underlying issue that a single heavy writer will block other async writes for a looong time.

But how is the kernel to know which process is the "bad" one which should be punished ? Maybe this process that writes now lots does so because it's just about to finish (or dumping core :-)) so it's more advantageous to give it a bit of priority because it won't bother anymore afterwards. On the other hand, if it's just writting and writting and not going away soon, it should be punished. So how can the kernel make the difference between these 2 situations ?

Quoted 5 lines

Another process comes along and writes 128K then closes the file. Before the close, it will call nfs_strategy() which will queue async writes after all the ones from dd. So, effectively, how quickly dd completes will determine how quickly this process can return from close.

If the second process is writting to the same file, then I think that this behaviour is actually wanted (of course, without locking, the data will be messsed up...).
If they are writting to different files, probably it makes sense to make sure that both files advance a bit, so queueing based on inode might also make sense.

Queueing based on PID is probably bad also from another point of view:
a process can have more than one file open at the same time and can do various operations on them. If it writes a lot to one file and then wants to read a small piece from another file, should it have to wait until the writes are done to perform the read ?

Signature · 17 lines
Bogdan Costescu

IWR - Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen
Universitaet Heidelberg, INF 368, D-69120 Heidelberg, GERMANY
Telephone: +49 6221 54 8869, Telefax: +49 6221 54 8868
E-mail: [email protected]



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#4 lore raw

På må , 01/03/2004 klokka 10:18, skreiv Bogdan Costescu:

Quoted 2 lines · Shantanu Goel

But how is the kernel to know which process is the "bad" one which

should be punished ? Maybe this process that writes now lots does so because it's just about to finish (or dumping core :-)) so it's more advantageous to give it a bit of priority because it won't bother anymore afterwards. On the other hand, if it's just writting and writting and not going away soon, it should be punished. So how can the kernel make the difference between these 2 situations ?

I'm currently working on a scheme for throttling processes that keep on scheduling new writes while the VM is trying to free up memory.

Quoted 1 line

If the second process is writting to the same file, then I think that

this behaviour is actually wanted (of course, without locking, the data will be messsed up...).

Writes always take the i_sem semaphore, so no problems with mess ups. I've already got patches for improving the caching in the above case (we basically get rid of nfs_strategy() and leave the job of deciding when to schedule the writes to pdflush).

Quoted 1 line

If they are writting to different files, probably it makes sense to

make sure that both files advance a bit, so queueing based on inode might also make sense.

Agreed.

Quoted 1 line

Queueing based on PID is probably bad also from another point of view:

a process can have more than one file open at the same time and can do various operations on them. If it writes a lot to one file and then wants to read a small piece from another file, should it have to wait until the writes are done to perform the read ?

In practice you can have several processes competing for the same reads, writes etc. I'd prefer to treat reads and writes as "belonging" to the mapping rather than to any one process...

For synchronous operations, however, a pid (or equivalent) is fine...

Cheers,
Trond

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

På må , 01/03/2004 klokka 10:58, skreiv [email protected]:

Quoted 2 lines

I'm currently working on a scheme for throttling processes that keep on scheduling new writes while the VM is trying to free up memory.

OK... This is now ready for testing as part of the latest NFS4_ALL patch. See

http://www.fys.uio.no/~trondmy/src/Linux-2.6.x/2.6.3/linux-2.6.3-22-congestion.dif

Cheers,
Trond

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#7 lore raw
In reply to a message not in the archive

På må , 01/03/2004 klokka 10:03, skreiv Shantanu Goel:

Quoted 1 line

Not a matter of being difficult. It won't fix the underlying issue

that a single heavy writer will block other async writes for a looong time. Here's the scenario. dd makes a huge bunch of nfs_strategy() calls and fills up the async queue. Another process comes along and writes 128K then closes the file. Before the close, it will call nfs_strategy() which will queue async writes after all the ones from dd. So, effectively, how quickly dd completes will determine how quickly this process can return from close. What you need is a way to tell the scheduler that the async writes from the latter process are not

Quoted 1 line

the same as the ones from dd. Using the pid is one such approach,

though as you pointed out probably not the best one. Another would be the cookie approach. Each rpc_message has a cookie field. The NFS layer sets the cookie to be the inode. The scheduler implements the multiple priority queues but at the same priority level, round-robins between different cookies. Does that clear it up?

Not entirely.

Simple round robin is not going to play well with NFSv2 style write gathering on the server. Nor will it really work too efficiently with standard readahead.
How about instead doing round-robin on blocks of, say, 16 requests per cookie (which is the current maximum readahead value)? That should allow the server some efficiency on block operations without sacrificing your fairness criterion.

Note: to avoid having to revamp rpc_call_sync() to take a cookie all the time, you could have rpc_init_task() set the default cookie to be a pointer to the thread's task_struct. For the particular case of read/write ops, the NFS layer can modify that cookie to be a pointer to the inode.

Cheers,
Trond

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

På må , 01/03/2004 klokka 10:58, skreiv Shantanu Goel:

Quoted 1 line
Quoted 1 line

Simple round robin is not going to play well with NFSv2 style write

gathering on the server. Nor will it really work too efficiently with standard readahead.

Quoted 1 line
Quoted 1 line

How about instead doing round-robin on blocks of, say, 16 requests per

cookie (which is the current maximum readahead value)? That should allow

Quoted 1 line
Quoted 1 line

the server some efficiency on block operations without sacrificing your

fairness criterion.

Quoted 2 lines
Quoted 1 line

We could make it static but how about we add a field "nr_batch" to

rpc_clnt with a default of 16 but let the higher layer override it? This way the NFS layer can set it to a different value for different servers.

If you want to make it tunable, then I suggest you just make it a global variable, and set it up as a sysctl in /proc/sys/sunrpc. I doubt there is much call for making this a per-mountpoint variable (we already have too many tunables in the "mount" structure as it is).

Cheers,
Trond

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs