This is an archive of the discontinued LLVM Phabricator instance.

[mlir][StorageUniquer] Use allocators per thread instead of per shard
ClosedPublic

Authored by rriddle on Mar 13 2023, 3:00 PM.

Details

Summary

This greatly reduces the number of allocators we create, while still
retaining thread safety. Reducing the number of allocators is much
better for locality and memory usage; this revision drops memory
usage for some MLIR heavy workloads (with lots of attributes/types)
by >=5%. This is due to the observation that the number of threads
is effectively always smaller than the number of parametric attributes/types.

Diff Detail

Event Timeline

rriddle created this revision.Mar 13 2023, 3:00 PM
rriddle requested review of this revision.Mar 13 2023, 3:00 PM
rriddle updated this revision to Diff 504900.Mar 13 2023, 5:32 PM

This assumes less threads than shards overall right?

rriddle added a comment.EditedMar 13 2023, 5:43 PM

This assumes less threads than shards overall right?

Yeah, which is effectively always a guarantee (even on my beefy desktop) given the number of parametric builtin attributes/types we have.

mehdi_amini accepted this revision.Mar 13 2023, 5:46 PM
mehdi_amini added inline comments.
mlir/lib/Support/StorageUniquer.cpp
166

Can you get the shard after this if?

This revision is now accepted and ready to land.Mar 13 2023, 5:46 PM

This assumes less threads than shards overall right?

Yeah, which is effectively always a guarantee (even on my beefy desktop) given the number of parametric builtin attributes/types we have.

Makes sense, maybe worth a note in the commit message to call it out explicitly.

rriddle updated this revision to Diff 504913.Mar 13 2023, 7:08 PM
rriddle edited the summary of this revision. (Show Details)
rriddle marked an inline comment as done.
rriddle added inline comments.Mar 13 2023, 7:09 PM
mlir/lib/Support/StorageUniquer.cpp
166

Nice catch, thanks!

Mogball accepted this revision.Mar 14 2023, 11:47 PM
Mogball added a subscriber: Mogball.

amazing