Introduce buffered I/O and replace getc with buffered read #647
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces 32k buffer for file I/O operations
and 32k buffer for fgetc() replacemnt routines.
This is follow-up of my work presented in pull request #642.
Some performance gain is observed and 'perf' trace does not
show getc operations at all, shifting the burden to actual
I/O system routines. In order to improve performance of these,
32k buffer is attached to every opened file by calling
setvbuf() function.
Due to suspicious way of passing pointers around in flang runtime,
all of the I/O buffers had to be allocated statically. In order to
prevent memory bloat, only limited number of simultaneously opened
files will be buffered, file descriptor ID is used for buffer
selection which is a thread-safe solution.
The test case I was using is following:
my_file.txt.gz
Compiled with gfortran it gives much better timing results that when compiled with flang. My patch improves the timing of flang compiled program.