This repository was archived by the owner on Jan 25, 2024. It is now read-only.
Avoid copies when passing binary parameters#1
Merged
robx merged 5 commits intoPostgREST:masterfrom Sep 5, 2022
Merged
Conversation
There were two identical copies each of the parameter mangling code.
Instead of building a list of 'Int' in the fold, and then mapping 'toEnum' over it, build a list of 'CInt' directly.
We encode various arrays of the same length through 'withArray'. Each of these computes the length, so we might as well take the length from one of these.
steve-chavez
approved these changes
Sep 5, 2022
robx
added a commit
to robx/postgrest
that referenced
this pull request
Sep 5, 2022
This pulls in the change from PostgREST/postgresql-libpq#1.
robx
added a commit
to robx/postgrest
that referenced
this pull request
Sep 5, 2022
This pulls in the change from PostgREST/postgresql-libpq#1.
robx
added a commit
to robx/postgrest
that referenced
this pull request
Sep 5, 2022
This pulls in the change from PostgREST/postgresql-libpq#1.
robx
added a commit
to PostgREST/postgrest
that referenced
this pull request
Sep 5, 2022
This pulls in the change from PostgREST/postgresql-libpq#1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
ByteStringuses 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