From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59919 invoked by alias); 3 Mar 2015 16:12:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 59906 invoked by uid 89); 3 Mar 2015 16:12:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 03 Mar 2015 16:12:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2A413D3284; Tue, 3 Mar 2015 11:11:59 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2709X+E2GVhD; Tue, 3 Mar 2015 11:11:59 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id EF2C2D312B; Tue, 3 Mar 2015 11:11:58 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 0986B40EAD; Tue, 3 Mar 2015 08:11:58 -0800 (PST) Date: Tue, 03 Mar 2015 16:12:00 -0000 From: Joel Brobecker To: "Yichun Zhang (agentzh)" Cc: gdb-patches Subject: Re: [PATCH] [python] Optimize python_string_to_host_string() for Python 2. Message-ID: <20150303161157.GC3243@adacore.com> References: <1421217481-18204-1-git-send-email-agentzh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1421217481-18204-1-git-send-email-agentzh@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-03/txt/msg00097.txt.bz2 Hello, First of all, sorry about the delay in review this. I was hoping that someone more knowledgeable than I would be able to review it. Thanks for ping us, and for your patience! > I have been writing quite some advanced GDB Python tools for LuaJIT > and NGINX in the nginx-gdb-utils project [1] and have been suffering > from serious performance issues even for relatively small working sets. > > I have noticed from a typical on-CPU C-land Flame Graph [2] > for my tools that python_string_to_host_string() is painfully slow > when using Python 2 (2.7 to be more specific) due to the > expensive and meaningless unicode conversions there (involved with > hot function calls like utf_8_decode). [...] > gdb/ChangeLog: > > * python/py-utils.c (python_string_to_host_string): use > xstrdup directly for Python 2. > * python/py-utils.c (gdbpy_obj_to_string): use > python_string_to_host_string for both Python 2 and 3. I believe you, but being a fairly complete dummy in this area, can you explain why the unicode conversion is meaningless with Python 2? In fact, if you have that explanation, I think it would be useful to have that as a comment inside the Python-2 part of python_string_to_host_string. Thanks, -- Joel