This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] [python] Optimize python_string_to_host_string() for Python 2.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: "Yichun Zhang (agentzh)" <agentzh at gmail dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Tue, 3 Mar 2015 08:11:58 -0800
- Subject: Re: [PATCH] [python] Optimize python_string_to_host_string() for Python 2.
- Authentication-results: sourceware.org; auth=none
- References: <1421217481-18204-1-git-send-email-agentzh at gmail dot com>
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