Page MenuHomePhabricator

[MLIR] Use a shared uniquer for affine maps and integer sets.
ClosedPublic

Authored by ulysseB on Dec 2 2021, 3:44 AM.

Details

Summary

Affine maps and integer sets previously relied on a single lock for creating unique instances. In a multi-threaded setting, this lock becomes a contention point. This commit updates AffineMap and IntegerSet to use StorageUniquer instead. StorageUniquer internally uses sharded locks and thread-local caches to reduce contention. It is already used for affine expressions, types and attributes. On my local machine, this gives me a 5X speedup for an application that manipulates a lot of affine maps and integer sets.

This commit also removes the integer set uniquer threshold. The threshold was used to avoid adding integer sets with a lot of constraints to the hash_map containing unique instances, but the constraints and the integer set were still allocated in the same allocator and never freed, thus not saving any space expect for the hash-map entry.

Diff Detail

Event Timeline

ulysseB created this revision.Dec 2 2021, 3:44 AM
ulysseB requested review of this revision.Dec 2 2021, 3:44 AM
rriddle accepted this revision.Dec 2 2021, 11:14 AM

Nice cleanup, thanks!

This revision is now accepted and ready to land.Dec 2 2021, 11:14 AM
This revision was automatically updated to reflect the committed changes.