Change regcache list to be an hash map inferior-thread-map-2020-01-16
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 16:39:29 +0000 (11:39 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 16 Jan 2020 22:19:41 +0000 (17:19 -0500)
commitb0eb7e3ea662525545e60fcb092272afaa1cddb2
treefb71a6e0837477795c7233300e38320f776c7fdc
parent2301204a3b3cd6553f7490498b3adc5973157c1b
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.
gdb/gdbsupport/ptid.h
gdb/regcache.c
gdb/regcache.h
gdb/thread-map.h
This page took 0.025229 seconds and 4 git commands to generate.