haskell / haskell/bytestring

Make safe/unsafe foreign calls size dependent

Open
#282 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
301
Forks
144
Avg merge
7d 22h
Merged PRs (30d)
1

Description

In https://github.com/haskell/bytestring/blob/master/Data/ByteString/Internal.hs#L747, we import `memcpy` as an unsafe FFI call, which means that it runs "inline" and will block all other Haskell threads running on the same capability in the threaded runtime. If the Bytestring being copied is very large, this might block the other Haskell threads for longer than is desired.

In the [crypto libraries](https://github.com/haskell-hvr/cryptohash-sha256/blob/6982f9e8269b8ed3d5196013fda271f2726daef1/src/Crypto/Hash/SHA256.hs#L166-L176), there are both safe and unsafe imports which are switched between depending on the size of the input. This trick might be useful here as well.

Interested to hear your opinions about this, I can pick it up if this is something desired.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.