From: Howard C. <hy...@hi...> - 2007-03-13 02:03:04
|
I just noticed while building under VMware that my system was processing some 80,000 reads per second while running a Makefile, spending 90+% time in kernel mode and only about 6% in user mode. This was with the previous bash 2.x, but I installed bash 3.1 and got the same behavior. Basically bash is never using buffered I/O; it's reading script files one character at a time. This behavior is totally unnecessary. This patch fixes the behavior: Index: input.c =================================================================== RCS file: /cvsroot/mingw/msys/packages/bash/3.1/input.c,v retrieving revision 1.2 diff -u -r1.2 input.c --- input.c 11 Aug 2006 17:21:39 -0000 1.2 +++ input.c 13 Mar 2007 02:00:16 -0000 @@ -337,7 +337,7 @@ #if ! (__CYGWIN__ || __MSYS__) # define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0) #else -# define fd_is_seekable(fd) 0 +# define fd_is_seekable(fd) 1 #endif /* __CYGWIN__ */ /* Take FD, a file descriptor, and create and return a buffered stream Note that fd_is_seekable() is only used in one place, to determine whether to buffer the input or not. Also there's no harm in always returning true, because a non-seekable descriptor will return a 0 in statbuf.st_size, and there's already a check for that condition, which will revert to the single-character reads. -- -- Howard Chu Chief Architect, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc Chief Architect, OpenLDAP http://www.openldap.org/project/ |