mjr@decuac.dec.com (Marcus J. Ranum) (11/08/90)
What are some cases when I'd want to use readv() instead of read()? I understand the advantages of being able to break things into several buffers (and possibly avoid having to move data around) but does using writev() give me some kind of possible performance improvement? Does writev() help block my data into popular buffer sizes or something like that ? If I have 2 iovecs with 500 and 524 bytes respectively is the operation performed analogous to write(fd,buf,1024) or is it simply write(fd,buf1,500), write(fd,buf2,524) with the kernel just doing the legwork? I see I still have to sum up the sizes of the contents of the scatter/gather arrays so I can check the return of the write - doesn't it get kind of icky when you have a partial writev()? Please let's *NOT* get into a bOring 6-week long discussion about checking return values. Suffice to say I do. :) mjr.
chris@mimsy.umd.edu (Chris Torek) (11/08/90)
In article <1990Nov8.041357.29013@decuac.dec.com> mjr@decuac.dec.com (Marcus J. Ranum) writes: > If I have 2 iovecs with 500 and 524 bytes respectively is the >operation performed analogous to write(fd,buf,1024) or is it simply >write(fd,buf1,500), write(fd,buf2,524) with the kernel just doing >the legwork? The latter (except, potentially, to a character device, but there are no character devices in any Unix I have seen that do anything special with multiple IO vectors). > I see I still have to sum up the sizes of the contents of the >scatter/gather arrays so I can check the return of the write - doesn't >it get kind of icky when you have a partial writev()? Yes, it does. This is one of the reasons I elected not to use writev() in my stdio implementation (which has a stdio-level writev-like function whose main raison d'etre is printf()). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris