[Patch, fortran, RFC] PR 40958 Reduce size of module files

Mikael Morin mikael.morin@sfr.fr
Mon Nov 28 16:14:00 GMT 2011


On Saturday 26 November 2011 23:33:27 Janne Blomqvist wrote:
> I think it's possible to fix the current system without redesigning it
> from the ground up, though one can of course argue whether starting
> from a clean sheet would be easier. What I think would be needed, at
> least, is roughly:
> 
> 1. Parse a .mod file in one go without any seeking.
> 
> 2. My patch to compress the contents (as your tests show, this step
> clearly depends on step #1).
> 
> 3. The "module namespace" thing, that is, parsing and storing a
> representation of a module in memory once per translation unit rather
> than redoing it every time we encounter a USE statement.
> Unfortunately, this thing seems harder than what one would expect at
> first glance; it has been talked about for years but nobody has found
> the time to do it.
> 
> I think that if these three issues were solved, gfortran module
> handling would be good enough for all practical purposes.
Yes, 1) and 3) can (have to?) be done together, because:
 - either we load only the needed stuff, in which case we have to seek;
   consider for example the case where we use only a procedure pulling in a
   type for its interface, itself pulling a bunch of components, themselves
   pulling more types etc. We don't know in advance all the things we'll have
   to load, so we'll have to seek back (or forth) as they become marked needed
   (this is the current behaviour).
 - or, if we don't want to seek, we'll have to load everything, which makes
   3) reachable.

> 
> PS: Heck, what about a simple and stupid approach for #1: Just read
> the mod file into a big string, and then do the parsing from there?
> Then a rudimentary implementation of #3 would be to just store
> pointers to all the strings we have so far read, and the mod file name
> in order to look it up.
Yes, but in the case of a 400+ MB module file, it would be paging vs seeking, 
so the benefits might not be as high as expected.


Another possible approach, if fat module files affect especially OOP code:
let's remove the frontend-generated (mostly OOP-related AFAIK) variables from 
modules. I mean the vtab, vtype, and all that stuff. It should be possible to 
regenerate them from the inheritance information (also dumped to modules) so 
their presence is not strictly needed, or is it?

Mikael



More information about the Fortran mailing list