This repository was archived by the owner on Jan 25, 2024. It is now read-only.
Avoid copies when passing binary parameters #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is haskellari#22, filed against this forked repo. As with
hasql-pool
, hoping to get this upstream eventually, but let's move forward like this for now.Currently, the library copies every input parameter when passing it to libpq via
Data.ByteString.useAsCString
. This PR avoids those copies for the case of binary parameters, by usingData.ByteString.Unsafe.unsafeUseAsCString
.I claim that this is safe because:
ByteString
uses pinned memoryThere are a few preparatory commits to factor out duplicate code to
withParams
, and to avoid a bit of unnecessary work there.Context is PostgREST/postgrest#2261. We see significant decrease of memory use with this change: PostgREST/postgrest#2349