teslamotors / fixed-containers

C++ Fixed Containers
MIT License
352 stars 31 forks source link

Fixed unordered map clear #118

Open Bobobalink opened 1 month ago

Bobobalink commented 1 month ago

I ran some benchmarks on different clear options: 1) just try_emplace into the new map 2) the process in this PR (including the scary-looking memcopy) 3) the process in this PR used for constexpr contexts (no memcopy)

Screenshot 2024-06-19 at 7 50 30 PM

The above graph was created with a "fresh" map, starting empty and then pushing each element once. This means the linked list is in perfect order so we don't see the locality issues of using linked lists. Instead, I generated a "used" linked list by repeatedly deleting and replacing subsets of the array, yielding the following results:

Screenshot 2024-06-19 at 7 51 04 PM