Hello Donald,
Saturday, May 20, 2006, 8:55:06 AM, you wrote:
> We've talked a bit about further tuning the ForiengPtr type for its use
> in ByteString. Now I've got some numbers.
i think that the following is slightly wrong:
+ (MallocPtr _ ref) -> ref
+ _ -> error "GHC.ForeignPtr: attempt to finalize a
ForeignPtr without finalizers"
instead this function should look:
finalizeForeignPtr :: ForeignPtr a -> IO ()
finalizeForeignPtr (ForeignPtr _ (PlainMallocPtr _)) = return ()
finalizeForeignPtr (ForeignPtr _ RawAddress) = return ()
finalizeForeignPtr (ForeignPtr _ foreignPtr) = do
finalizers <- readIORef refFinalizers
sequence_ finalizers
writeIORef refFinalizers []
where
refFinalizers = case foreignPtr of
(PlainForeignPtr ref) -> ref
(MallocPtr _ ref) -> ref
because user don't need to know whether this ForeignPtr has any
finalizers or not - he just should be able to ensure that all them
will be performed
i written your personal email because thought that you implemented
this patch entirely inside the ByteString module, that would allow to
get in ghc 6.4 the same speed as you got for ghc 6.5
nevertheless, this patch should also help for 6.6 - first, it will
decrease memory requirement for each ByteString on 12 bytes, what is
important when you hold millions of small strings in memory. second, it
should decrease time required to build each string that is again
important when you create large number of small strings
if some of your tests create large number of small strings, you should
see improvements in these tests
--
Best regards,
Bulat mailto:[EMAIL PROTECTED]
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc