Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Vyacheslav Egorov <vegorov@chromium.org>
Cc: Pedro Alves <pedro@codesourcery.com>, gdb@sourceware.org
Subject: Re: JIT interface slowness
Date: Mon, 03 Jan 2011 17:32:00 -0000	[thread overview]
Message-ID: <AANLkTi=bfvZsweD6Ycy+qVq2v9y7bbtuf7VRaqUggWfk@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikaJe+M3zqjkB6J6J8Ec5QROnf6WbcKQ=0Yh=7u@mail.gmail.com>

On Mon, Jan 3, 2011 at 2:43 AM, Vyacheslav Egorov <vegorov@chromium.org> wrote:

> I thought that setting a breakpoint requires O(1) not O(n). It's a bit
> disappointing.

I think I've mis-diagnosed the problem slightly -- there is no breakpoint
inserted into every JITted ELF. But there is still a quadratic loop in jit.c:

/* Look up the objfile with this code entry address.  */

static struct objfile *
jit_find_objf_with_entry_addr (CORE_ADDR entry_addr)
{
  struct objfile *objf;
  CORE_ADDR *objf_entry_addr;

  ALL_OBJFILES (objf)
    {
      objf_entry_addr = (CORE_ADDR *) objfile_data (objf, jit_objfile_data);
      if (objf_entry_addr != NULL && *objf_entry_addr == entry_addr)
        return objf;
    }
  return NULL;
}

...
static void
jit_inferior_init (struct gdbarch *gdbarch)
...
  /* If we've attached to a running program, we need to check the descriptor to
     register any functions that were already generated.  */
  for (cur_entry_addr = descriptor.first_entry;
       cur_entry_addr != 0;
       cur_entry_addr = cur_entry.next_entry)
    {
      jit_read_code_entry (gdbarch, cur_entry_addr, &cur_entry);

      /* This hook may be called many times during setup, so make sure we don't
         add the same symbol file twice.  */
      if (jit_find_objf_with_entry_addr (cur_entry_addr) != NULL)
        continue;

      jit_register_code (gdbarch, cur_entry_addr, &cur_entry);
    }

This is quadratic if you insert all 1000 JITted ELFs and call the
__jit_debug_register_code() once.

If you call __jit_debug_register_code() after adding every new ELF,
you get N*N*N instead :-(

My gut feeling though is that the really slow operation here is
jit_read_code_entry (which reads target memory) and everything else is
noise in comparison (but I haven't measured it).  Assuming this is so,
you get O(N) if you call __jit_debug_register_code once, and O(N*N) if
you call it after every new ELF.

I think we could do much better if we keep a "shadow" copy of the list of
JITted ELFs in GDB, instead of re-reading it from inferior all the time.

Let me try to come up with a patch ...


> I will have to emit debug information (namely .debug_frame)
> for all code object otherwise gdb is not able to unwind stack properly
> on x64.

This is slightly incorrect: you must emit .eh_frame{,_hdr} for any
x86_64 code if you want stack unwinder to work, but you don't need to emit
any debug info (IOW, .debug_frame is not required).

Cheers,
-- 
Paul Pluzhnikov


  reply	other threads:[~2011-01-03 17:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-31 19:43 Vyacheslav Egorov
2010-12-31 20:10 ` Pedro Alves
2010-12-31 21:39   ` Vyacheslav Egorov
2010-12-31 22:23     ` Pedro Alves
2010-12-31 23:12       ` Vyacheslav Egorov
2010-12-31 23:36         ` Pedro Alves
2011-01-02  7:54           ` Paul Pluzhnikov
2011-01-03 10:44             ` Vyacheslav Egorov
2011-01-03 17:32               ` Paul Pluzhnikov [this message]
2011-01-03 22:01                 ` Paul Pluzhnikov
2011-01-03 23:32                   ` Pedro Alves
2011-01-03 23:40                     ` Pedro Alves
2011-01-03 23:47                     ` Paul Pluzhnikov
2011-01-04  0:13                       ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTi=bfvZsweD6Ycy+qVq2v9y7bbtuf7VRaqUggWfk@mail.gmail.com' \
    --to=ppluzhnikov@google.com \
    --cc=gdb@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=vegorov@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox