This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix performance inconsistency between unordered_map copy-assignment and copy-construction
Needs ReviewPublic

Authored by ldionne on Mar 11 2022, 1:49 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

We were not rehashing the hash table before performing assignment, which
resulted in greatly sub-optimal performance when compared to the
otherwise equivalent copy constructor.

This patch also adds a test that will start failing should a performance
difference be reintroduced in the future.

rdar://89335436

Diff Detail

Event Timeline

ldionne created this revision.Mar 11 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 1:49 PM
ldionne requested review of this revision.Mar 11 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 1:49 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Just curious can you share the before and after timings of this change?

libcxx/include/unordered_set
601

Please update the description/title to mention unordered_set and the multi versions.

libcxx/test/libcxx/containers/unord/perf.assignment_vs_construction.pass.cpp
10

This raises the same questions as this test for D121485.