This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __register_frame_info and unwinding shared libraries


On Wed, Mar 02, 2005 at 03:03:36PM +0000, Andrew Haley wrote:
> This implements a cache of header info.
...
> As this is to some extent a fix for a performance regression, I'd like
> it to be considered for 4.0.

Thanks a lot, looks good to me (though I can't approve it), I'd even vote
for it being considered for 3.4 as well.
I just wonder if the data->check_cache = 0; shouldn't be moved.

> @@ -135,6 +155,82 @@ _Unwind_IteratePhdrCallback (struct dl_p
>    p_eh_frame_hdr = NULL;
>    p_dynamic = NULL;
>  
> +  struct frame_hdr_cache_element *prev_cache_entry = NULL,
> +    *last_cache_entry = NULL;
> +
> +  if (data->check_cache && size >= sizeof (struct ext_dl_phdr_info))
> +    {
> +      static unsigned long long adds = -1ULL, subs;
> +      struct ext_dl_phdr_info *einfo = (struct ext_dl_phdr_info *) info;
> +

Here...

> +      /* We use a least recently used cache replacement policy.  Also,
> +	 the most recently used cache entries are placed at the head
> +	 of the search chain.  */
> +
> +      if (einfo->dlpi_adds == adds && einfo->dlpi_subs == subs)
> +	{
> +	  /* Find data->pc in shared library cache.
> +	     Set load_base, p_eh_frame_hdr and p_dynamic
> +	     plus match from the cache and goto
> +	     "Read .eh_frame_hdr header." below.  */
...
> +	  /* Initialize the cache.  Create a chain of cache entries,
> +	     with the final one terminated by a NULL link.  */
> +	  int i;
> +	  for (i = 0; i < FRAME_HDR_CACHE_SIZE; i++)
> +	    {
> +	      frame_hdr_cache[i].pc_low = 0;
> +	      frame_hdr_cache[i].pc_high = 0;
> +	      frame_hdr_cache[i].link = &frame_hdr_cache[i+1];
> +	    }
> +	  frame_hdr_cache[i-1].link = NULL;
> +	  frame_hdr_cache_head = &frame_hdr_cache[0];
> +	  data->check_cache = 0;

... from here.
Otherwise, I'm afraid if no new libraries have been dlopened and no libs
dlclosed since last _Unwind_Find_FDE call and you don't hit the cache,
you'll search the cache for every library searched rather than only
the first one.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]