[PATCH 1/2] gdb/python: replace linked list with unordered_set

Simon Marchi simark@simark.ca
Thu Nov 18 16:13:43 GMT 2021


>> An alternative with less overhead than an unordered_set but still fits
>> the requirements (I think) would be to make the list an intrusive_list.
>> I keeps the existing data structure, but makes it more friendly to
>> use.
>
> I'll rewrite this patch as you suggest, OOI, is there one aspect of
> the overhead that concerns you the most?  I might be able to collect
> some performance data...

No, nothing specific.  It's just that the linked list solution seems
better and more lightweight from a theoritical point of view.  If I look
at the operations we need to do:

 - assert that a value is in values_in_python
 - remove a value from values_in_python
 - insert a value in values_in_python
 - iterate over all values in values_in_python

All these operations are as quick or faster with the linked list than
with the unordered set, in addition to requiring less memory
allocation and processing, so it just seems like a no-brainer to me.

I used to hate dealing with linked lists, but only because we had all
these separate ugly implementations that fiddled with pointers.  I find
that intrusive_list makes using them much easier and less error-prone.

Simon


More information about the Gdb-patches mailing list