Thanks a lot!

I've updated the benchmark accordingly, and have released a new version without the 1.3x slowdown disclaimer as generic-hashable 1.1.8.

  - Clark


On Sun, Nov 4, 2012 at 10:25 AM, Herbert Valerio Riedel <hvr@gnu.org> wrote:
Clark Gaebel <cgaebel@uwaterloo.ca> writes:

[...]

> Oh yeah, and if anyone wants to help me figure out why it's 1.3x slower
> than my hand-rolled instances, that would be really helpful.

[...]

I've taken a look at the bench/Bench.hs benchmark[1]:

The generated Core looks almost[2] the same as your 'HandRolled'; but
the 1.3x slow-down factor seems to be caused by the way the
'bigGenericRolledDS' CAF is defined in the test-harness: if I define it
explicitly (i.e. just as 'bigHandRolledDS' is defined, and not as an
isomorphic transformation of the 'bigHandRolledDS' value) the benchmark
results in both versions having more or less equal performance as would
be expected.


 [1]: https://github.com/wowus/hashable-generics/blob/master/bench/Bench.hs

 [2]: with the following change, it would look exactly the same (modulo
      alpha renamings):

--8<---------------cut here---------------start------------->8---
--- a/bench/Bench.hs
+++ b/bench/Bench.hs
@@ -18,7 +18,7 @@ data GenericRolled = GR0
     deriving Generic

 instance Hashable HandRolled where
-    hashWithSalt salt HR0       = hashWithSalt salt $ (Left () :: Either () ())
+    hashWithSalt salt HR0       = hashWithSalt salt $ ()
     hashWithSalt salt (HR1 mi)  = hashWithSalt salt $ (Right $ Left mi :: Either () (Either (Maybe Int) ()))
     hashWithSalt salt (HR2 x y) = hashWithSalt salt $ (Right $ Right (x, y) :: Either () (Either () (HandRolled, HandRolled)))
--8<---------------cut here---------------end--------------->8---

hth,
hvr

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe