Closed raehik closed 1 year ago
@nikita-volkov This seems to be the culprit of some of the performance improvements I was seeing in my library, specifically for serializing lots of small-ish bytestrings.
Note that there are no benchmarks for bytestring serialization currently.
Mentioned in #15. Note included in bytestring compat module copied here:
GHC 9.0 made
withForeignPtr
sound at the cost of performance. If you want to use the faster unsafe implementation, it's now atunsafeWithForeignPtr
, and GHC asks you to promise that your continuation does not diverge. All we do here ismemcpy
bytestrings, so we gladly pinky swear. For more detail, see Ben Gamari's post: https://www.haskell.org/ghc/blog/20210607-the-keepAlive-story.htmlNote that fumieval's mason uses
unsafeWithForeignPtr
in the same way also to copy bytestrings.