Change regcache list to be an hash map
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 16:39:29 +0000 (11:39 -0500)
committerLaurent Morichetti <laurent.morichetti@amd.com>
Thu, 23 Apr 2020 22:21:35 +0000 (15:21 -0700)
commit4c530be873f1ca2ccd7b545dd2752cf27baa0ba5
tree08b2bc41638144a8888d7da2d87fbf73fe32ce15
parent227c8c56e81aa9ee2afd45c859c8ae8592da05d6
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: I01c9af327b472422b432b71b6c4737424839d254
gdb/gdbsupport/ptid.h
gdb/regcache.c
gdb/regcache.h
gdb/thread-map.h
This page took 0.026043 seconds and 4 git commands to generate.