public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dmitry.neverov at jetbrains dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug mi/31324] New: -var-create: slowdown due to children printing
Date: Thu, 01 Feb 2024 12:17:56 +0000	[thread overview]
Message-ID: <bug-31324-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31324

            Bug ID: 31324
           Summary: -var-create: slowdown due to children printing
           Product: gdb
           Version: 14.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: mi
          Assignee: unassigned at sourceware dot org
          Reporter: dmitry.neverov at jetbrains dot com
  Target Milestone: ---

Fix for https://sourceware.org/bugzilla/show_bug.cgi?id=11335
changed the logic of -var-create. Before, if a var had children,
-var-create returned "{...}" as a value. Now, it appends the
pretty printer's to_string result to the printed children.

It looks like there is no way to disable this behavior.

New logic has performance implications. For example, running

  -var-create v1 * "ss"

in the following program:

typedef struct {
  int x, y;
} SlowStruct;

int main() {
  SlowStruct ss[100] = {0};
  return 0; //break
}

will be slow if SlowStruct has a slow pretty-printer:

import gdb
import gdb.printing
import time

class SlowStructPrinter:
    def __init__(self, val):
        self.val = val

    def to_string(self):
        time.sleep(1)
        return ("slow struct")

def slowStructPrinterMatcher(val):
    if "SlowStruct" in str(val.type):
        return SlowStructPrinter(val)

gdb.pretty_printers.append(slowStructPrinterMatcher)

This was fast in 13.2, because children were not printed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2024-02-01 12:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 12:17 dmitry.neverov at jetbrains dot com [this message]
2024-02-01 12:51 ` [Bug mi/31324] " dmitry.neverov at jetbrains dot com
2024-02-01 16:20 ` tromey at sourceware dot org
2024-02-02  9:07 ` dmitry.neverov at jetbrains dot com

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=bug-31324-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).