Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unordered map clear #118

Merged

Conversation

Bobobalink
Copy link
Contributor

@Bobobalink Bobobalink commented Jun 8, 2024

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

@Bobobalink Bobobalink marked this pull request as ready for review June 12, 2024 01:56
@Bobobalink Bobobalink force-pushed the fixed_unordered_map_clear branch 4 times, most recently from 58b37d0 to a4ad920 Compare June 12, 2024 18:11
This was the source of a bug in FixedUnorderedMap for
non-TriviallyCopyably types caused by retaining indices into the
LinkedList's underlying storage, but the old copy/move logic would
change the locations of the stored values. The new operations instead
place the values at the same indices of the destination storage.
This exercises edge cases in the copy and move constructors and
assignment operators for value types that are nontrivial.
@alexkaratarakis alexkaratarakis merged commit 41f5073 into teslamotors:main Jul 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants