[Git][ghc/ghc][wip/sjakobi/udfm-placement] UDFM: don't INLINE udfmToList (fixes T17836 alloc regression)
Simon Jakobi pushed to branch wip/sjakobi/udfm-placement at Glasgow Haskell Compiler / GHC Commits: 966e260a by Simon Jakobi at 2026-07-08T07:00:19+02:00 UDFM: don't INLINE udfmToList (fixes T17836 alloc regression) Commit 6990e63f made udfmToList INLINE so its n <= 1 case would fuse with its consumer. But udfmToList's one hot consumer -- traverseUSDFM in the pattern-match checker -- doesn't fuse, and inlining the size dispatch into it regressed the T17836 ghc/alloc perf test. Unlike eltsUDFM, which is called on ~2M singleton maps by fusing consumers in T13719, udfmToList fuses too rarely (~60k singleton calls) to earn its INLINE. Assisted-by: Claude Opus 4.8 - - - - - 1 changed file: - compiler/GHC/Types/Unique/DFM.hs Changes: ===================================== compiler/GHC/Types/Unique/DFM.hs ===================================== @@ -504,12 +504,13 @@ udfmRestrictKeysSet (UDFM val_set i) set = -- as this already incurs most of the cost of returning the full list. -- See Note [Cost of deterministic iteration]. udfmToList :: UniqDFM key elt -> [(Unique, elt)] -{-# INLINE udfmToList #-} -- so the small case is a good producer +-- NB: no INLINE, unlike eltsUDFM. udfmToList's one hot consumer is +-- traverseUSDFM in the pattern-match checker, which doesn't fuse. Inlining +-- the size dispatch into it regresses T17836. udfmToList (UDFM m ub) -- n <= 1: any order is trivially tag order, so read straight off the map | M.compareSize m 1 /= GT = - build (\c n -> - M.foldrWithKey (\k tv r -> c (mkUniqueGrimily k, taggedFst tv) r) n m) + M.foldrWithKey (\k tv r -> (mkUniqueGrimily k, taggedFst tv) : r) [] m | otherwise = to_list_nonempty m ub -- Precondition: m is non-empty View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/966e260a14667b5f21f73088356e88e1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/966e260a14667b5f21f73088356e88e1... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Jakobi (@sjakobi2)