Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: "Marc Khouzam" <marc.khouzam@ericsson.com>
Cc: <gdb-patches@sourceware.org>
Subject: RE: [PATCH:MI] Return a subset of a variable object's children
Date: Thu, 01 May 2008 12:06:00 -0000	[thread overview]
Message-ID: <18457.45600.692401.191218@kahikatea.snap.net.nz> (raw)
In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA042910B5@ecamlmw720.eamcs.ericsson.se>

 > > > Also, the double loop may prove to be slow for large number of children.
 > > 
 > > I was thinking that only a small number of children would ever exist
 > > simultaneously.  Scrolling might make that a larger number but maybe
 > > it could be arranged to delete children that go out of view.
 > 
 > You are right, we do that in DSF-GDB.  However, such a double loop can become
 > prohibitive relatively quickly, at numbers lower than when children start
 > being deleted.  For example, DSF-GDB allows for 1000 varObjs simultaneously,
 > before doing any deletion.  This may not prove too slow, but it creates
 > a requirement on the frontend to do proper management of varObjects, to
 > avoid any issues.  If we can avoid the double loop (and its string
 > comparisons), we would benefit, no?

The double loop is O(N*N).  I guess it could be reduced to O(N*log(N))
using some kind of sorting algorithm.

 > > > I was thinking that we could keep order of children as they are defined
 > > > (current behaviour) but not fill them all, until requested.
 > > > We could create the full Vector of children as is done now by
 > > > 
 > > >   while (VEC_length (varobj_p, var->children) < var->num_children)
 > > >     VEC_safe_push (varobj_p, var->children, NULL);
 > > 
 > > I guess this would remove the need for a second loop but it seems wasteful
 > > on memory.  Previously children variable objects were stored as a linked
 > > list and, as I have said before, I do think this is more suitable as
 > > objects can then be inserted and removed at any point in the sequence of
 > > children.
 > 
 > Yes, linked list seem more suited for this usecase.  But I gather from
 > Volodya's emails that vectors have benefits that we should not ignored, so
 > let's continue the discussion with vectors.  To me, the advantage of your
 > patch is far larger in the fact that we no longer need to create all
 > children varObj at once; my impression is that the memory allocation is a
 > small optimization in caparison.  Is that a correct impression?  Besides,
 > currently, the memory is immediately allocated, so things wouldn't be any
 > worse :-)

It's not just a question of memory allocation.  It's computationally
inefficient because Gdb has to traverse a large sparsely populated vector every
time it operates on it.  It wouldn't be any _worse_ than current Gdb, but I was
trying to make it significantly _better_.

 > > > We can even improve on that by doing the following: instead of
 > > > allocating the vector for all children, we can allocate the vector for
 > > > the children up to start+number*stride.
 > > 
 > > The variables start, number and stride might be selectable by the user but
 > > I'm thinking that "number" used by Gdb will be controlled by how many
 > > elements are visible on the screen.  What happens with your approach when
 > > new elements become visible and new children need to be created?
 > 
 > Here is a simplified example.  Say you have an array of a 1000 integers and
 > we can show 10 elements on the screen.  The user 'opens' the array,
 > revealing the first 10 elements.  The user then jumps-scrolls to position
 > 500 revealing postions 500 to 509.  I imagine a set of commands to be
 > something like this:
 > 
 > -var-list-children -f 0 -n 10 var1
 > -var-list-children -f 500 -n 10 var1
 > 
 > The first call to var-list-children would allocate a vector of size (number+start = 0+10).
 > And create those 10 children varObjs.
 > The second call would expand that vector to a size of (number+start = 500+10).
 > And create those 10 children varObjs.
 > Positions 10 to 499 would remain NULL since we haven't create the children yet (and we may
 > never create them, if the user does not scroll there.)
 > 
 > Is that what you were asking?

It looks like it's only a big saving if the user never moves far from the
start of the array.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


  reply	other threads:[~2008-05-01 12:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-27 15:34 Nick Roberts
2008-04-29 15:58 ` Marc Khouzam
2008-04-30  7:02   ` Nick Roberts
2008-04-30  9:20     ` Vladimir Prus
2008-04-30  9:25       ` Nick Roberts
2008-04-30  9:39         ` Vladimir Prus
2008-04-30 16:29           ` Marc Khouzam
2008-05-01 15:56             ` Vladimir Prus
2008-05-01 17:29               ` Marc Khouzam
2008-05-01 12:15           ` Nick Roberts
2008-05-10 14:45             ` Nick Roberts
2008-05-28 19:15               ` Vladimir Prus
2008-05-29 12:01                 ` Nick Roberts
2008-04-30 16:22         ` Marc Khouzam
2008-05-01 15:54           ` Vladimir Prus
2008-05-01 18:14             ` Marc Khouzam
2008-05-01 18:40               ` Vladimir Prus
2008-05-01 20:49                 ` Daniel Jacobowitz
2008-05-01 23:38                   ` Nick Roberts
2008-05-02  0:58                 ` Marc Khouzam
2008-05-11 17:45                   ` Vladimir Prus
2008-04-30 10:47       ` André Pönitz
2008-04-30 12:20         ` Vladimir Prus
2008-04-30 12:53           ` André Pönitz
2008-04-30 13:11             ` Vladimir Prus
2008-04-30 12:44         ` Nick Roberts
     [not found]           ` <200804301244.55116.apoenitz@trolltech.com>
2008-04-30 13:16             ` André Pönitz
2008-05-01  6:27               ` Nick Roberts
2008-05-05 11:46                 ` André Pönitz
2008-04-30 14:59     ` Marc Khouzam
2008-05-01 12:06       ` Nick Roberts [this message]
2008-05-01 14:22         ` Marc Khouzam
2008-05-01 20:41     ` Daniel Jacobowitz
2008-04-30  8:59 ` Vladimir Prus

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=18457.45600.692401.191218@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=gdb-patches@sourceware.org \
    --cc=marc.khouzam@ericsson.com \
    /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