This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, libgfortran] PR25949 Excessive memory usage due to buffering.


Hi,

Attached patch fixes one case I found were the library uses excessive
memory.

It also avoids calling lseek() unless necessary just before a read()
or write(). This should fix an issue brought up by Bud Davis a long
time ago, where unformatted sequential performance was slow on NFS due
to the need to lseek() back and fix the record size, and then lseek()
forwards to the end of the record again. As long as the markers and
the record fits in the buffer, this is no longer an issue with this
patch. Unfortunately there is still one unnecessary lseek():in
occuring per record, so it's not optimal yet.

Also some minor cleanup/simplification.

Regtested on i686-pc-linux-gnu. Ok for trunk? It's a quite minor fix
after all, so I don't think it should go into 4.1.

libgfortran ChangeLog:

2006-01-25  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/io.h: Add set function pointer to struct stream.  
	* io/unix.c (fd_seek): Only update offset, don't seek.
	(fd_sset): New function.
	(fd_read): Call lseek directly if necessary.
	(fd_write): Likewise.
	(fd_open): Set pointer to fd_sset.
	(mem_set): New function.
	(open_internal): Set pointer to mem_set.
	* io/transfer.c (write_block_direct): Rename to write_buf, add
	error return, non-pointer length argument.
	(unformatted_write): Update to use write_buf.
	(us_write): Simplify by using swrite instead of salloc_w.
	(write_us_marker): New function.
	(new_record_w): Use sset instead of memset, use write_us_marker,
	simplify by using swrite instead of salloc_w.


-- 
Janne Blomqvist

Attachment: pr25949.diff
Description: Text document

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]