public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [gnat] reuse of ASTs already constructed
@ 2012-04-06 20:24 oliver.kellogg
  2012-04-10 10:20 ` Arnaud Charlet
  0 siblings, 1 reply; 44+ messages in thread
From: oliver.kellogg @ 2012-04-06 20:24 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1571 bytes --]

I am finally finding some some time to continue this work,
having left off with
  http://gcc.gnu.org/ml/gcc/2009-08/msg00475.html :

> [...]
> There are two problems right now:
> 
> 1) Mixing of Ada.Text_IO and Text_IO as described at
>    http://gcc.gnu.org/ml/gcc-help/2009-08/msg00113.html

The solution to this one turned out to be quite simple, see attached patch.
Sem_Ch12.Analyze_Package_Instantiation calls Rtsfind.Text_IO_Kludge,
and the latter contains:

          if Chrs in Text_IO_Package_Name then
             for U in Main_Unit .. Last_Unit loop
                Get_Name_String (Unit_File_Name (U));
                ...
On compiling the second file, Main_Unit is not 0 but some larger value.
The existing node for Text_IO was not being found because it is at an
index smaller than the current Main_Unit. The solution was to start the
loop at index 0.

I will now start looking into the second problem,

> 2) The 'X' lines in the ALI files are not what they should be.
> This is due to the fact that Lib.Xref.Generate_(Definition|Reference) is
> called during semantic analysis. However, when I discover that a
> tree was already built for a main unit by a previous compilation,
> Sem is not redone for that tree. Depending on whether
> Lib.Xref.Initialize is called per-job or per-file, this leads to either
> too much or too little cross ref info.

By the way, I am currently using trunk r152433 (4.5.0 pre-release) and
moving forward to the 4.5.0 release.
When that is done: Should I continue on trunk or switch to the
gcc-4_5-branch ?

Thanks,

Oliver

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch; name="rtsfind.adb.diff", Size: 472 bytes --]

Index: rtsfind.adb
===================================================================
--- rtsfind.adb	(revision 152433)
+++ rtsfind.adb	(working copy)
@@ -1406,7 +1406,7 @@
       --  or [Wide_]Wide_Text_IO already loaded, then load the proper child.
 
       if Chrs in Text_IO_Package_Name then
-         for U in Main_Unit .. Last_Unit loop
+         for U in 0 .. Last_Unit loop
             Get_Name_String (Unit_File_Name (U));
 
             if Name_Len = 12 then

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2012-07-07 20:33 Oliver Kellogg
  0 siblings, 0 replies; 44+ messages in thread
From: Oliver Kellogg @ 2012-07-07 20:33 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1560 bytes --]

At http://gcc.gnu.org/ml/gcc/2012-06/msg00332.html,
Arnaud Charlet wrote:

> > In multi source compilations, main units may get assigned different
> > unit numbers than in single source compilations; this is due to the
> > reuse of entries in the Lib.Units table.
> > 
> > Is that tolerable?
> 
> You'd need to check whether the IDEs (in particular GPS) will not have
> troubles with this.

It turns out that in this case, my analysis was incorrect.
The reason for the different unit numbers in 'X' lines is that a few
dependencies ('D' lines) are missing. I will look into that soon.

Meanwhile, I have made some comparisons between single and multi
file compilations. For a package hierarchy consisting of 262 specs
totalling 82164 SLOC and 77 bodies totalling 135771 SLOC, compiling
the bodies yields the following results.

1. many gnat1 invocations without Ada syntax tree sharing

time gcc -S *.adb
real    9m12.159s
user    4m59.391s
sys     0m7.061s

time gcc -S -g *.adb
real    9m59.429s
user    8m57.776s
sys     0m5.750s

2. single gnat1 invocation with Ada syntax tree sharing

time gcc -multi -S *.adb
real    4m22.915s
user    3m34.466s
sys     0m2.900s

time gcc -multi -S -g *.adb
real    7m16.770s
user    6m29.554s
sys     0m2.711s

I have not been able to compare optimizing compilation due
to a crash in multi mode when using the -O switch.
(Right now I'm still concentrating on the front end, and I will
look into that later.)

The comparison was done using the attached patch which is
against gcc/trunk r177548 of 2011-08-07.

-- Oliver

[-- Attachment #2: Type: application/x-gzip, Size: 42427 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2012-06-23 18:22 Oliver Kellogg
  2012-06-23 22:23 ` Arnaud Charlet
  0 siblings, 1 reply; 44+ messages in thread
From: Oliver Kellogg @ 2012-06-23 18:22 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

Hello,

The patch attached at http://gcc.gnu.org/ml/gcc/2012-06/msg00261.html
was just barely enough to get gnat1 compiled but failed on compiling the
rts files.  Please replace it by the patch here.  (This one is against
gcc/trunk r162542 of 2010-07-26 but I'm moving forward these days.)

One occasional ALI difference wrt single compile mode is the unit
number appearing in 'X' lines, for example:

--- single/blanks_to_underscores.ali  2012-06-23 18:15:09
+++ multi/blanks_to_underscores.ali   2012-06-23 19:07:39
@@ -7,20 +7,17 @@
 .....
-X 3 blanks_to_underscores.adb
+X 1 blanks_to_underscores.adb

In multi source compilations, main units may get assigned different
unit numbers than in single source compilations; this is due to the
reuse of entries in the Lib.Units table.

Is that tolerable?

Thanks,

Oliver


On 2012-06-17 17:12, Oliver Kellogg wrote:
> 
> Continuing on from http://gcc.gnu.org/ml/gcc/2012-04/msg00654.html,
> [...]
> Here is my current patch (against trunk r158428), plus a test case
> that demonstrates the fix for the problem described, and also shows
> remaining problems with ALI generation in the multi source compile
> mode.
> 

[-- Attachment #2: Type: application/x-gzip, Size: 38052 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2012-06-17 15:12 Oliver Kellogg
  0 siblings, 0 replies; 44+ messages in thread
From: Oliver Kellogg @ 2012-06-17 15:12 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]

Continuing on from http://gcc.gnu.org/ml/gcc/2012-04/msg00654.html,

> I looked into the second problem from
> http://gcc.gnu.org/ml/gcc/2009-08/msg00475.html ,
> 
> > 2) The 'X' lines in the ALI files are not what they should be.
> > This is due to the fact that
> > Lib.Xref.Generate_(Definition|Reference) is called during semantic
> > analysis. However, when I discover that a tree was already built for
> > a main unit by a previous compilation, Sem is not redone for that
> > tree. [...]
> > 
> 
> and I see two possible solutions:
> 
> 1) Extend Lib.Xref.Generate_Reference, Sem_Util.Process_End_Label and
> others for the case "not In_Extended_Main_Source_Unit" in multi source
> compilation mode to buffer the generated references for possible later
> consumption by the main unit for which they are intended.
> If the main unit is not part of the main units given in the multi
> source compile job then the buffered data can be discarded.
> 
> 2) Determine an ordering of the main units such that main units with
> little or no dependencies precede main units that depend on them.
> Submit units to semantic analysis in the determined order.

The second approach would have entailed earth shaking changes to the
GNAT code base so I chose the first approach.
Here is my current patch (against trunk r158428), plus a test case that
demonstrates the fix for the problem described, and also shows remaining
problems with ALI generation in the multi source compile mode.

Oliver



[-- Attachment #2: Type: application/x-gzip, Size: 40540 bytes --]

[-- Attachment #3: Type: application/x-gzip, Size: 1365 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2012-04-15 19:22 oliver.kellogg
  0 siblings, 0 replies; 44+ messages in thread
From: oliver.kellogg @ 2012-04-15 19:22 UTC (permalink / raw)
  To: gcc

I looked into the second problem from
  http://gcc.gnu.org/ml/gcc/2009-08/msg00475.html ,

> 2) The 'X' lines in the ALI files are not what they should be.
> This is due to the fact that Lib.Xref.Generate_(Definition|Reference) is
> called during semantic analysis. However, when I discover that a
> tree was already built for a main unit by a previous compilation,
> Sem is not redone for that tree. [...]

and I see two possible solutions:

1) Extend Lib.Xref.Generate_Reference, Sem_Util.Process_End_Label
and others for the case "not In_Extended_Main_Source_Unit" in multi
source compilation mode to buffer the generated references for possible
later consumption by the main unit for which they are intended.
If the main unit is not part of the main units given in the multi source
compile job then the buffered data can be discarded.

2) Determine an ordering of the main units such that main units with
little or no dependencies precede main units that depend on them.
Submit units to semantic analysis in the determined order.

Both approaches seem quite heavy.
Solution 2 looks more elegant to me. OTOH this would require a
separate analysis of the with clauses prior to invoking Sem proper.

Oliver



^ permalink raw reply	[flat|nested] 44+ messages in thread
[parent not found: <1240349826.4554.76.camel@tidbit.site>]
* Re: [gnat] reuse of ASTs already constructed
@ 2009-04-13 16:30 Oliver Kellogg
  2009-04-14 14:10 ` Oliver Kellogg
                   ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Oliver Kellogg @ 2009-04-13 16:30 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

Picking up an old thread,
http://gcc.gnu.org/ml/gcc/2003-03/msg00281.html


On Tue, 4 Mar 2003, Geert Bosch <bosch at gnat dot com> wrote:
> [...]
> Best would be to first post a design overview,
> before doing a lot of work in order to prevent spending time
> on implementing something that may turn out to have fundamental
> problems.

I've done a little experimenting to get a feel for this.

I've looked at the work done toward the GCC compile server but
decided that I want to concentrate on GNAT trees (whereas the
compile server targets the GNU trees.)

Also I am aiming somewhat lower - not making a separate compile
server process but rather extending gnat1 to handle multiple
files in a single invocation.

The current GNAT code makes a strong assumption that there be
only one main unit, and this Main_Unit be located at index 0 of
Lib.Units.Table (see procedure Lib.Load.Load_Main_Source).

I am currently looking at having each main unit supplied on
the gnat1 command line overwrite the Main_Unit in the Units table.

What do you think of this approach?

The attached patch sets the stage for passing multiple source
files to a single gnat1 invocation. (Beware, this is a rough cut.
Best use "svn diff --diff-cmd diff -x -uw" after applying as
there are many changes that only affect indentation.)

Thanks,

Oliver



[-- Attachment #2: gnat1_multi_source_compile-0.diff.gz --]
[-- Type: application/x-gzip, Size: 9248 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2003-03-04 22:03 Robert Dewar
  0 siblings, 0 replies; 44+ messages in thread
From: Robert Dewar @ 2003-03-04 22:03 UTC (permalink / raw)
  To: Oliver.Kellogg, dewar; +Cc: gcc

> Ah, could you point me to those discussions?
> Are they here on this list?
> (I found searching for "gnat" difficult because there are
> too many hits on "gnats".)

No I am talking about internal discussions at ACT, dating back several years. We never
pursued them because as I said, the gains seemed small compared to the effort, and
other things have had higher priority.

> Would you consider inclusion into GNAT if someone implemented this?

Sure, but I would suggest that what is needed first is a very careful design which
gets discussed before even one line of code is written (that's the procedure we always
follow internally). The reason that this is particularly important is that there are
lots of delicate interactions here.

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [gnat] reuse of ASTs already constructed
@ 2003-03-04 20:42 Robert Dewar
  2003-03-04 21:01 ` Oliver Kellogg
  0 siblings, 1 reply; 44+ messages in thread
From: Robert Dewar @ 2003-03-04 20:42 UTC (permalink / raw)
  To: Oliver.Kellogg, gcc

> I think it's a terrible waste that gnat1 can only process
> one single file.
> If gnat1 could be invoked with (for example) all the files
> that gnatmake finds to need recompilation, that could
> give tremendous compilation time savings - by keeping the
> syntax trees of units compiled for reuse by further units.
> 
> Many Ada projects have large package specs that tend
> to be pervasively used. (The GNAT compiler is itself
> an example of such a design.) These applications
> could benefit a lot from in-memory AST reuse.
> 
> What do you think about this?

It's definitely techncially feasible (probably with some compilation server
approach, and we have discussed more than once what might be involved), but
right now it is not on our radar screen, since front end compilation time (which
is what this would save) is not a critical issue for us in the total picture.

^ permalink raw reply	[flat|nested] 44+ messages in thread
* [gnat] reuse of ASTs already constructed
@ 2003-03-04 17:08 Oliver Kellogg
  2003-03-04 20:07 ` Geert Bosch
  0 siblings, 1 reply; 44+ messages in thread
From: Oliver Kellogg @ 2003-03-04 17:08 UTC (permalink / raw)
  To: gcc

Hello developers of GNAT,

I think it's a terrible waste that gnat1 can only process
one single file.
If gnat1 could be invoked with (for example) all the files
that gnatmake finds to need recompilation, that could
give tremendous compilation time savings - by keeping the
syntax trees of units compiled for reuse by further units.

Many Ada projects have large package specs that tend
to be pervasively used. (The GNAT compiler is itself
an example of such a design.) These applications
could benefit a lot from in-memory AST reuse.

What do you think about this?

Thanks,

Oliver Kellogg

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2012-07-07 20:33 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-06 20:24 [gnat] reuse of ASTs already constructed oliver.kellogg
2012-04-10 10:20 ` Arnaud Charlet
  -- strict thread matches above, loose matches on Subject: below --
2012-07-07 20:33 Oliver Kellogg
2012-06-23 18:22 Oliver Kellogg
2012-06-23 22:23 ` Arnaud Charlet
2012-06-17 15:12 Oliver Kellogg
2012-04-15 19:22 oliver.kellogg
     [not found] <1240349826.4554.76.camel@tidbit.site>
     [not found] ` <49EE4D58.8020404@adacore.com>
     [not found]   ` <1240437226.4554.101.camel@tidbit.site>
     [not found]     ` <49EF9892.1010703@adacore.com>
     [not found]       ` <1246487007.4507.76.camel@tidbit.site>
2009-08-26 18:39         ` Oliver Kellogg
2009-09-27 22:48           ` Oliver Kellogg
2009-04-13 16:30 Oliver Kellogg
2009-04-14 14:10 ` Oliver Kellogg
2009-04-19 18:48 ` Oliver Kellogg
2009-04-20  5:14   ` Oliver Kellogg
2009-05-03 21:14     ` Oliver Kellogg
2009-05-03 21:17       ` Robert Dewar
2009-05-03 21:22         ` Oliver Kellogg
2009-05-04  1:14           ` Robert Dewar
2009-05-04  5:31             ` Oliver Kellogg
2009-05-04 12:23               ` Dave Korn
2009-05-09 20:09               ` Oliver Kellogg
2009-05-09 20:42                 ` Robert Dewar
2009-06-15 20:38                   ` Oliver Kellogg
2009-06-17  4:20                     ` Oliver Kellogg
2009-06-28 22:45                   ` Oliver Kellogg
2009-05-08 21:13       ` Tom Tromey
2009-04-20 18:40 ` Geert Bosch
2009-04-20 20:34   ` Oliver Kellogg
2009-04-20 21:12     ` Geert Bosch
2009-04-20 21:35       ` Oliver Kellogg
2009-04-27  6:18       ` Oliver Kellogg
2009-04-27  8:29         ` Robert Dewar
2009-04-27 18:36         ` Ian Lance Taylor
2009-04-27 18:47           ` Oliver Kellogg
2009-04-27 19:47         ` Tom Tromey
2009-04-27 22:09           ` Oliver Kellogg
2009-04-27 22:26             ` Tom Tromey
2009-04-27 22:44               ` Oliver Kellogg
2003-03-04 22:03 Robert Dewar
2003-03-04 20:42 Robert Dewar
2003-03-04 21:01 ` Oliver Kellogg
2003-03-04 22:03   ` Geert Bosch
2003-03-04 17:08 Oliver Kellogg
2003-03-04 20:07 ` Geert Bosch
2003-03-04 20:49   ` Oliver Kellogg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).