[rfa/dwarf] Support for attributes pointing to a different CU

Jim Blandy jimb@redhat.com
Tue Oct 5 16:13:00 GMT 2004


Daniel Jacobowitz <drow@false.org> writes:
> On Tue, Oct 05, 2004 at 12:04:26AM -0500, Jim Blandy wrote:
> > The only advantage I had in mind was simplicity, and it didn't seem
> > like it'd be a performance hit.
> > 
> > The libiberty hash table expands by a given ratio each time, which
> > means that, overall, the number of rehashings per element is constant
> > no matter how large the table gets.  It's similar to the analysis that
> > shows that ye olde buffer doubling trick ends up being linear time.
> > (I'm thinking on my own here, not quoting anyone, so be critical...)
> > 
> > There could be a locality disadvantage to doing it all in one big hash
> > table.  When the time comes to restore a given CU's types, their table
> > entries will be sharing cache blocks with those of other, irrelevant
> > CU's.  That doesn't happen if we use for per-CU hash tables: table
> > entries will never share cache blocks with table entries for other
> > CU's (assuming the tail of one table doesn't share a block with the
> > head of another, blah blah blah...).
> > 
> > I'm concerned about the legacy of complexity we'll leave.  Wrinkles
> > should prove they can pay their own way.  :)
> 
> Then there's only one thing to do... I'll time it.
> 
> Using a per-objfile type_hash saves a little memory in overhead, and
> probably a little more in hash table size - I didn't instrument memory
> use.  But it's definitely slower.  From 1% to 4.3% depending on the
> test case.
> 
> I believe this happens because we can create the per-comp-unit hash
> tables at the correct size - I use a heuristic based on the size of the
> CU, although by this point I could use a more accurate one based on the
> number of DIEs if I thought it would be worthwhile.  If we create a
> per-objfile CU, then we don't get this benefit, so we do a lot of
> copying.  There's also the locality benefit.
> 
> Also, it saves no code - unless you see something I'm missing, it was
> basically s/cu->per_cu->type_hash/dwarf2_per_objfile->type_hash/.  So,
> OK with the per-comp-unit hash?

Yep, that's fine.  Thanks for persuing it; I'm comfortable with this
now.



More information about the Gdb-patches mailing list