This is an archive of the discontinued LLVM Phabricator instance.

[MemProf] Avoid global lock when updating MIB cache
ClosedPublic

Authored by tejohnson on Sep 15 2021, 2:09 PM.

Details

Summary

Previously we used a global Allocator-scope mutex to lock when adding a
deallocation to the MIB cache. This resulted in a lot of contention.
Instead add and use per-set mutexes.

Along with this, we now need to remove the global miss and access count
variables and instead utilize the per-set statistics to report the
overall miss rate.

Diff Detail

Event Timeline

tejohnson requested review of this revision.Sep 15 2021, 2:09 PM
tejohnson created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 2:09 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
snehasish accepted this revision.Sep 15 2021, 3:13 PM

LGTM with one minor comment.

compiler-rt/lib/memprof/memprof_allocator.cpp
347

Since you are touching these lines, can you update the format specifiers to match the data types?
Same for the loop below.

It would clean up some of the errors I am seeing with -Wformat - e.g.
warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘__sanitizer::u64’

This revision is now accepted and ready to land.Sep 15 2021, 3:13 PM
tejohnson added inline comments.Sep 15 2021, 3:25 PM
compiler-rt/lib/memprof/memprof_allocator.cpp
347

Ah, I build with -Wno-format, so was missing these. If it is ok with you, since there are quite a few from various lines when I remove that option, I will commit those fixes as a separate change.

snehasish added inline comments.Sep 15 2021, 3:28 PM
compiler-rt/lib/memprof/memprof_allocator.cpp
347

A separate cleanup patch with the option removed sounds better. Thanks!

This revision was automatically updated to reflect the committed changes.
tejohnson added inline comments.Sep 15 2021, 4:29 PM
compiler-rt/lib/memprof/memprof_allocator.cpp
347