Change regcache list to be an hash map inferior-thread-map-2020-06-30
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 16:39:29 +0000 (11:39 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 1 Jul 2020 00:01:10 +0000 (20:01 -0400)
commit5d5aa92e2295b048c3c8eb04d7238b83127aada1
tree193c3cdb7fc5829950574e979bdb63317ec875f6
parentff3ca435d94571fbfcfbe24e996e8e6010075911
Change regcache list to be an hash map

The regcache objects created for threads are stored in a linked list,
regcache::current_regcache.

This may result in bad performance when debugging a lot of threads, as GDB
needs to walk the linked list to fetch a regcache given a ptid.

This patch replaces the linked list with an std::unordered_map, indexed by
(ptid, arch).  The lookups, in get_thread_arch_aspace_regcache, should become
faster when the number of threads grow.  With a small number of threads, it
will probably be a bit slower to do an hash map lookup than to walk a few
linked list nodes,  but it should not be perceptible.

The function registers_changed_ptid deletes all regcaches related to a given
ptid (there could be multiple, with different arches).  Since the hash map is
indexed by (ptid, arch), we can't do a simple lookup, so we fall back on
iterating on all the hash map values.  It should be the same complexity as what
we have today.  This function is called when resuming execution, so it would be
nice to find a more efficient way to do this.

Similarly, the function regcache_thread_ptid_changed is called when a thread
changes ptid, so it needs to look up all regcaches for a given ptid.  This one
also iterates on all the hash map values.  However, it is not called often
(mostly when creating an inferior, on some specific platforms), so it shouldn't
be a problem.

Change-Id: Iabb0a1111707936ca111ddb13f3b09efa83d3402
gdb/regcache.c
gdb/regcache.h
gdb/thread-map.h
gdbsupport/ptid.h
This page took 0.02428 seconds and 4 git commands to generate.