[commit: ghc] wip/tdammers/T15019: Fix simplCast perf issues from #14737 (5a157f8)
git at git.haskell.org
git at git.haskell.org
Mon Apr 30 09:28:37 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/tdammers/T15019
Link : http://ghc.haskell.org/trac/ghc/changeset/5a157f8032633804d9c2f7ba7d558e9d99ad1e78/ghc
>---------------------------------------------------------------
commit 5a157f8032633804d9c2f7ba7d558e9d99ad1e78
Author: Tobias Dammers <tdammers at gmail.com>
Date: Mon Apr 30 09:33:59 2018 +0200
Fix simplCast perf issues from #14737
See Trac #15019.
Reflexive coercion performance is a surprisingly delicate matter. On the
one hand, we want to eliminate reflexive coercions as early as possible,
to avoid performance bottlenecks later on; on the other hand,
conclusively doing so involves calling `eqType`, which is expensive.
In #14737, we addressed the `eqType` part by simply removing the
`eqType` check. This, however, causes regressions, because the check no
longer catches some of the reflexive coercions that we want to catch.
So we need to find a balance between getting rid of reflexivity as soon
as it appears (see Trac #11735, #14737, #15019), and avoiding calls to
`isReflexiveCo` (which is expensive on big types, since it involves
`eqType`).
In particular, we want to behave well on
* e |> co1 |> co2
where the two happent to cancel out entirely. That is quite common;
e.g. a newtype wrapping and unwrapping cancel
* (f |> co) @t1 @t2 ... @tn x1 .. xm
Here we wil use pushCoTyArg and pushCoValArg successively, which
build up NthCo stacks. Silly to do that if co is reflexive.
A good compromise (determined experimentally) seems to be to call
isReflexiveCo
* when composing casts, and
* at the end
>---------------------------------------------------------------
5a157f8032633804d9c2f7ba7d558e9d99ad1e78
compiler/coreSyn/CoreOpt.hs | 6 ++++
compiler/simplCore/Simplify.hs | 70 ++++++++++++++++++++++++++-----------
testsuite/tests/perf/compiler/all.T | 12 ++++---
3 files changed, 63 insertions(+), 25 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5a157f8032633804d9c2f7ba7d558e9d99ad1e78
More information about the ghc-commits
mailing list