public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch 0/2] Accelerate symbol lookups 15x
Date: Mon, 20 Oct 2014 21:44:00 -0000	[thread overview]
Message-ID: <20141020214410.GA22011@host2.jankratochvil.net> (raw)

Hi,

this patchset has been developed+tested only on top of
	[patchv2] Fix 100x slowdown regression on DWZ files
	https://sourceware.org/ml/gdb-patches/2014-10/msg00031.html

While this patchset is technically independent the GDB performance and memory
requirements would not make testing of this patchset possible.

Originally I expected with the patch above (fixing backtrace performance) even
the sluggish interactive GDB performance would get fixed.  It was not fixed.
During debugging I get 10-30 seconds for a response to simple commands like:
	(gdb) print vectorvar.size()

With this patch the performance gets to 1-2 seconds which is somehow
acceptable.  The problem is that dwarf2_gdb_index_functions.lookup_symbol
(quick_symbol_functions::lookup_symbol) may return (and returns) NULL even for
symbols which are present in .gdb_index but which can be found in already
expanded symtab.  But searching in the already expanded symtabs is just too
slow when there are 400000+ expanded symtabs.  There would be needed some
single global hash table for each objfile so that one does not have to iterate
all symtabs.  Which .gdb_index could perfectly serve for, just its
lookup_symbol() would need to return authoritative yes/no answers.

Even after such fix these two simple patches are useful for example for
non-.gdb_index files.

One can reproduce the slugging interactive GDB performance with:
	#include <string>
	using namespace std;
	string var;
	class C {
	public:
	  void m() {}
	};
	int main() {
	  C c;
	  c.m();
	  return 0;
	}
g++ -o slow slow.C -Wall -g $(pkg-config --libs gtkmm-3.0)
gdb ./slow -ex 'b C::m' -ex 'maintenance set per-command space' -ex 'maintenance set per-command symtab' -ex 'maintenance set per-command time' -ex r 
[...]
(gdb) p <tab><tab>
Display all 183904 possibilities? (y or n) n
(gdb) p/r var
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x3a4db073d8 <std::string::_Rep::_S_empty_rep_storage+24> ""}}
Command execution time: 20.023000 (cpu), 20.118665 (wall)
                        ^^^^^^^^^
Space used: 927997952 (+0 for this command)
#symtabs: 186099 (+0), #primary symtabs: 21573 (+0), #blocks: 290353 (+0)

For a non-trivial application with all symtabs expanded it takes 113 seconds.

Benchmark on non-trivial application without 'p <tab><tab>':
Command execution time:   0.496000 (cpu),   0.496882 (wall) --- both fixes
Command execution time:   0.899000 (cpu),   0.908062 (wall) --- just lookup_symbol_aux_objfile fix
Command execution time:   3.492000 (cpu),   3.491791 (wall) --- FSF GDB HEAD

Benchmark on non-trivial application with    'p <tab><tab>':
Command execution time:   7.373000 (cpu),   7.395095 (wall) --- both fixes
Command execution time:  13.572000 (cpu),  13.592689 (wall) --- just lookup_symbol_aux_objfile fix
Command execution time: 113.036000 (cpu), 113.067995 (wall) --- FSF GDB HEAD


No regressions on {x86_64,x86_64-m32,i686}-fedora21pre-linux-gnu in standard
and .gdb_index-enabled runs.  Neither of the patches should cause any visible
behavior change.


Jan

             reply	other threads:[~2014-10-20 21:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 21:44 Jan Kratochvil [this message]
2014-10-22  8:55 ` Doug Evans
2014-10-23 18:24   ` [patchv2 2/2] Accelerate lookup_symbol_aux_objfile 14.5x [Re: [patch 0/2] Accelerate symbol lookups 15x] Jan Kratochvil
2014-10-24  7:16     ` Doug Evans
2014-10-24  7:33       ` Jan Kratochvil
2014-10-24 16:07         ` Doug Evans
2014-10-27  5:55           ` Doug Evans
2014-10-27  6:02             ` Doug Evans
2014-10-27  8:54             ` Jan Kratochvil
2014-11-29 12:11       ` [patchv3 2/2] Accelerate lookup_symbol_aux_objfile 85x Jan Kratochvil
2014-12-02  3:07         ` Doug Evans
2014-12-03 18:05           ` Jan Kratochvil
2014-12-04  6:21             ` Doug Evans
2014-12-04  7:27               ` [commit] " Jan Kratochvil
2014-10-22  8:57 ` [patch 0/2] Accelerate symbol lookups 15x Doug Evans
2014-10-24  7:19 ` Doug Evans

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=20141020214410.GA22011@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@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).