haskell-streaming / streaming-bytestring

effectful sequences of bytes; an alternative no-lazy-io implementation of Data.ByteString.Lazy
BSD 3-Clause "New" or "Revised" License
16 stars 11 forks source link

Use faster unsafeWithForeignPtr for GHC 9.0+ #53

Closed vdukhovni closed 3 years ago

vdukhovni commented 3 years ago

With GHC 9.0 withForeignPtr was made safe for actions that might loop forever or always throw an exception. This safety comes at the cost of performance, the result is always allocated, which is not ideal for primitive byte-level memory operations.

A new unsafeWithForeignPtr is added that provides the old non-allocating behaviour when the action is sure to terminate. With GHC 9.0 and later, we use this function to loop over the content of ByteStream chunks.

fosskers commented 3 years ago

Nice, thanks for this. I'm going to add a CI job for GHC 9 now that it's available in Stackage Nightly. Once that's in, could you rebase onto master to make sure this all works with it too?

vdukhovni commented 3 years ago

Nice, thanks for this. I'm going to add a CI job for GHC 9 now that it's available in Stackage Nightly. Once that's in, could you rebase onto master to make sure this all works with it too?

Sure. There are some critical bugs in 9.0.1, but with a bit of luck we won't run into them... I hope 9.0.2 will be out soon.

fosskers commented 3 years ago

Taking care of this now.