Open GeorgeCo opened 1 week ago
The reason is that bv
is inlined in the vector
version, causing a new vector to be allocated each time bv
is used. This can be fixed by adding a {-# NOINLINE bv #-}
annotation.
Since you're using Vector Bool
as bit vectors, take a look at https://hackage.haskell.org/package/bitvec. It provides both faster and more memory efficient bit vectors.
Thanks for the quick and informative response! It certainly explains the performance difference but I'm surprised that it doesn't show up in bytes allocated. In any case I think we're agreed that this is a bug. IMHO and my less than expert knowledge it seems like a serious one. Thanks again!
I verified that, as you said , {-# NOINLINE bv #-} is a workaround for the problem
I don't think this is a bug in vector
. It could be a GHC bug though.
Thanks! Any ideas why the bug only happens with Vector and not with Array?
unboxed Vector Bool seems to be 8 times slower than unboxed Array Int Bool. As far as I can tell it is due to the performance difference in accessing array/vector elements. The following is with ghc 9.8.2 on an Intel Mac but I get about the same results on an M2 MacBook with ghc 9.10.1
prob171v.hs.txt prob171a.hs.txt