[darcs-users] darcs patch: optimize firstspace/firstnonspace to remove boxed retu...

Simon Marlow marlowsd at gmail.com
Fri Oct 2 11:43:35 UTC 2009


On 01/10/2009 17:33, Jason Dagit wrote:
> Could someone please review my patch?
>
> Ian gave a general objection to MagicHash, but I don't think that was
> intended as an actual review.
>
> I'm not sure who should be looking at this.

I'm not an official darcs reviewer, but I can comment if that would be 
helpful.

In general the patch is a kind of sledgehammer approach: using explicit 
unboxing is generally to be avoided if at all possible.  However, in 
performance-critical situations when you really want to be sure that 
you're getting the right Core, writing the unboxed code explicitly is 
more robust than relying on GHC to do the right thing.

I gather you tried other ways to optimise it and they didn't work.  From 
looking at the original code I'd expect that with a bit of refactoring 
and an INLINE pragma or two I hope that GHC could make the box go away. 
  Did you try just adding an INLINE to firstnonspace?

As I said though, the explicit unboxed version might be preferable for 
robustness reasons, although it does sacrifice portability to other 
compilers, if that's important.

Cheers,
	Simon


More information about the darcs-users mailing list