[Bug c++/22635] OVERLOAD should not be a linked list of trees

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Feb 22 14:01:00 GMT 2009



------- Comment #10 from steven at gcc dot gnu dot org  2009-02-22 14:01 -------
Trees were refactored, and we currently have:

struct tree_base
{
  ENUM_BITFIELD(tree_code) code : 16;
  /* 48 bits for various bitfield flags */
  union tree_ann_d *ann;
} /* So on a 64-bit host this is 128bits = 16 bytes */

struct tree_common
{
  struct tree_base; /* 16 bytes */
  tree chain; /* 8 bytes */
  tree type; /* 8 bytes */
}  /* So on a 64-bit host, tree_common is 32 bytes */

struct tree_overload
{
  struct tree_common; /* 32 bytes */
  tree function; /* 8 bytes */
}

So in total 40 bytes per tree_overload.  If a single linked list would really
be sufficient, then the ideal tree_overload would be 16 bytes (two pointers).
In reality, there are a few flags used on tree_overload, so two pointers is not
enough.  Let's say we use 4 bytes for that. Then we have an overhead of
(40/(16+4))*100% = 100% overhead.

In any normal engineering project, 100% overhead would be reason for distress.
However, as long as the G++ front end are comfortable using trees instead of
front-end specific structures in the parser, we can't do any better at this
point.  The overhead is much less than it was in the past.  It was 3% before
the tree refactoring, so it will be much less now.  And like Gaby already said:
If there are not so many of them (tree_overload objects) then it is not very
important (to squeeze out every last bit of overhead).

Therefore, closing as FIXED by Dan's refactoring.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22635



More information about the Gcc-bugs mailing list