[darcs-devel] Use System.Directory.copyFile for file copying

Salvatore Insalaco kirby81 at gmail.com
Fri Jul 20 00:27:14 PDT 2007


2007/7/19, Jason Dagit <dagit at codersbase.com>:
> I'm trying to understand why System.Directory.copyFile would be
> preferred.  Isn't it implemented in Haskell too?  Isn't bytestring (or
> rather PackedString) IO heavily optimized and on par with C?

Even if a performance comparison is the best thing to do, I think that
Kevin's observation is a good one.
If there's a standard library function to do X, unless there're good
reasons to not use it (e.g. compatibility with old library versions,
bad performance), it should be preferred to hand-made solutions.
If in GHC 6.x (or maybe y.x) they decide to improve it with a
super-fast-hardware-accelerated-sse-mmx-altivec-parallel algorithm, we
get the performance for free.

Anyway, in GHC 6.6.1, copyFile is implemented in Haskell with raw
buffered copy, using hGetBuf / hPutBuf.

For the same reason, I think that we should seriously think to switch
to ByteStrings. Isn't Darcs PackedString just a "prerelease" version
of ByteStrings? They have a pretty similar API. And now (in 6.7)
ByteStrings have a
super-fast-hardware-accelerated-sse-mmx-altivec-parallel algorithms
for stream fusion (more or less ;) ).

Salvatore


More information about the darcs-devel mailing list