Change regcache list to be an hash map inferior-thread-map-2019-12-18
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 16:39:29 +0000 (11:39 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 16:39:29 +0000 (11:39 -0500)
commit42b502299d428786938f90363cbfb62ae768cadb
tree2fe849575b0c2961a57f28607dbebe9e9c71b24b
parent4c449d978ae4916445678ca41993d280aa6854ed
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.02494 seconds and 4 git commands to generate.