This is an archive of the discontinued LLVM Phabricator instance.

[NFC][CodeGen] Use llvm::DenseMap for DeferredDecls
ClosedPublic

Authored by yurai007 on Jan 25 2022, 11:12 AM.

Details

Summary

CodeGenModule::DeferredDecls std::map operator[] seem to be hot especially while code generating huge compilation units.
In such cases using DenseMap instead gives observable compile time improvement. Patch was tested on Linux build with default config acting as benchmark.
Build was performed on isolated CPU cores in silent x86-64 Linux environment following: https://llvm.org/docs/Benchmarking.html#linux rules.
Compile time statistics diff produced by perf and time before and after change are following:
instructions -0.15%, cycles -0.7%, max-rss +0.65%.
Using StringMap instead DenseMap doesn't bring any visible gains.

Diff Detail

Event Timeline

yurai007 created this revision.Jan 25 2022, 11:12 AM
yurai007 requested review of this revision.Jan 25 2022, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 11:12 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.Jan 25 2022, 1:24 PM
erichkeane accepted this revision.Jan 25 2022, 1:30 PM

This looks fine to change, and seems like a slight compile timeimprovement.

It seems that the only thing we use this for is .find, .erase, and operator[], all of which don't depend on iterator order, so this should not cause any problems with determinism.

The change looks fine to me. I've started a set of benchmark to make sure it provides the expected speedup.

No performance regression on my side either (but only minor gains).

Thank you all for review!

This revision was landed with ongoing or failed builds.Jan 27 2022, 1:58 AM
This revision was automatically updated to reflect the committed changes.