[patch,libgfortran] PR37754 [4.4 Regression] READ I/O Performance regression from 4.3 to 4.4
Jerry DeLisle
jvdelisle@verizon.net
Fri Dec 26 01:28:00 GMT 2008
This is a Merry Christmas patch.
This patch recovers the performance from this regression by creating a stream
read_char function which is simply a trimmed down version of sread (fd_read). I
was actually surprised when I saw the test results. I suspect that the
simplification allows some better optimizations.
The patch also refactors next_char in list_read.c to eliminate goto's and
inlining a small portion of the "done:" code. The refactoring of next_char
alone gains 2.8% over current trunk. The use of the new read_char function
gains significant additional performance.
Using the countlines.f test case in the PR for comparison, average 5 runs.
gfortran 4.3: 3.357 seconds
gfortran 4.4 current trunk: 3.821 seconds
gfortran 4.4 patched: 3.164 seconds
This is a 5.7% improvement over 4.3 for this test case and 17% improvement over
current trunk.
I also believe this refactoring will make for some easier further improvements.
I don't know the status of Janne's patch so this patch may end up being short
lived. However, it is not very intrusive in the sense that it is mostly
reorganizing in simple ways our existing code paths. Since it involves a
regression, I think it would be OK for 4.4
Regression tested on x86-64.
OK to commit?
Jerry
2008-12-25 Jerry DeLisle
PR libgfortran/37754
* io/list_read.c (next_char): Factor out code for handling internal
units into a new function called next_char_iunit. Inline the code after
done and eliminate all goto's. Replace call to sread with new function
called sread_char. Move the incrementing of strm_pos to the end of the
function and get rid of the conditional.
(next_char_iunit): New function.
* io.h (stream): Add new function pointer, read_char, to structure.
Define new sread_char macro to call this function.
* unix.c (fd_read_char): Add this new function which is simply a
trimmed down version of fd_read. (fd_open): Set read_char pointer to
new function fd_read. (open_internal): Set read_char pointer
mem_read.
* transfer.c (formatted transfer_scalar): Remove this function by
factoring it into two new functions, one for read and one for right,
eliminating all the conditionals for read or write mode.
(formatted transfer_scalar_read): New function.
(formatted transfer_scalar_write): New function.
* write_float.def (output_float_FMT_G_): Update this macro to further
simplify the calculation of temp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newiopatch.diff
Type: text/x-diff
Size: 25365 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081226/6a2b8e12/attachment.bin>
More information about the Gcc-patches
mailing list