Closed sheaf closed 4 years ago
Actually, it seems I spoke too soon: the inspection test passes as long as one compiles with -O
. The problem is that profiling disables optimisations, causing these spurious inflated cost centres. Sorry for the noise.
No problem!
Forgive me if it isn't expected that the generics in this instance should be optimised away; please let me know if there are better ways to go about this. Thanks.
This is definitely one of the goals of this library. So don't hesitate to report any discrepancy you may find!
For instance, I believe there are issues with inlining for large types (around 10 fields or more). I would love to know if that's a problem for someone.
The following
Semigroup
instance seems to optimise poorly:I noticed this from the profiling output of an application which uses the above instance, which contained the following lines:
In this application, the
Semigroup ( Vector2D a )
was the only instance usinggmappend
; moreover, all the occurrences offrom'
are associated with this single instance.Switching to a hand-written instance made the other functions in the profiling report take up about 10% more of the total time, which corresponds to a significant speed up from writing
mappend
manually.Note that the same issue occurs if we use the newtype
Generically
instead ofGenericProduct
(with the necessary adjustments to the code to allow the instance to be derived).I've attached a quick (failing) inspection test using
inspection-testing
.gmonoid-inspection.zip
Forgive me if it isn't expected that the generics in this instance should be optimised away; please let me know if there are better ways to go about this. Thanks.