Experimental results splitting formatted read and write

Janne Blomqvist blomqvist.janne@gmail.com
Mon Dec 8 22:16:00 GMT 2008


Jerry DeLisle wrote:
> Jerry DeLisle wrote:
>> As an experiment, I split out the formatted_transfer_scaler into 
>> formatted_transfer_scaler_read and formatted_transfer_scaler_write 
>> finctions, eliminating all the if reading conditionals.
>>
> Some additional data from gprof: You can see that the processing of the 
> format string and "traversing" the format tokens is beginning to 
> dominate. For constant format strings, all of that could be done at 
> compile time and stored as a pointer to a token list or even a list of 
> format helper functions.  I wonder if g77 does anything like this?

I haven't measured it, but I've been stepping trough the code quite a 
lot with gdb when trying to debug my fbuf-getting-rid-of-salloc-etc. 
patch (I have a new hopefully better design, that roughly works but 
still lots of testsuite failures), and it's really a lot of code it 
trawls through, and it does it again and again.

That being said, parsing format strings is complicated enough, and in 
any case we need the capability to handle dynamic strings, so 
duplicating the format parser into the frontend for constant strings 
sounds a bit dubious IMHO. But one thing that might be worth thinking 
about would be that in the library we could have a cache of, say, 100 
parsed/compiled(?) format strings, perhaps indexed by a hash of the 
string? That way we wouldn't need two separate format parsers, and would 
avoid the overhead of repeatedly parsing the same format?

-- 
Janne Blomqvist



More information about the Fortran mailing list