-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce SQL sanitizer allocations #2136
Open
ninedraft
wants to merge
27
commits into
jackc:master
Choose a base branch
from
ninedraft:optimize-sanitize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4c1fda0
Add additional info for nullable pgtype types
mateuszkowalke 811b501
add byte length check to uint32
jennifersp 1a30a62
Use sql.ErrNoRows as value for pgx.ErrNoRows
ninedraft 19f1994
Release v5.7.0
jackc da51345
Fix data race with TraceLog.Config initialization
jackc 513a53f
Upgrade puddle to v2.2.2
jackc be67315
Update golang.org/x/crypto and golang.org/x/text
jackc e400c5e
Release v5.7.1
jackc 808da06
Fix prepared statement already exists on batch prepare failure
jackc fd6496f
Fix pgtype.Timestamp json unmarshal
s-montigny-desautels 21392a2
base case
ninedraft d8d0cab
add benchmark tool
ninedraft 9435a2c
buf pool
ninedraft 4f4e892
shared bytestring
ninedraft 39db71a
append AvailableBuffer
ninedraft e142286
docs
ninedraft f0180ba
quoteBytes
ninedraft c50cb14
quoteString
ninedraft 3a97ffd
decrease number of samples in go benchmark
ninedraft 1ec4baa
add FuzzQuoteString and FuzzQuoteBytes
ninedraft 000ce9c
add lexer and query pools
ninedraft 25a4bd3
rework QuoteString and QuoteBytes as append-style
ninedraft 2f3ae5a
add docs to sanitize tests
ninedraft 9a33a62
drop too large values from memory pools
ninedraft 85d5a4d
add prefix to quoters tests
ninedraft 97d8358
fix preallocations of quoted string
ninedraft 174e678
optimisations of quote functions by @sean-
ninedraft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
current_branch=$(git rev-parse --abbrev-ref HEAD) | ||
if [ "$current_branch" == "HEAD" ]; then | ||
current_branch=$(git rev-parse HEAD) | ||
fi | ||
|
||
restore_branch() { | ||
echo "Restoring original branch/commit: $current_branch" | ||
git checkout "$current_branch" | ||
} | ||
trap restore_branch EXIT | ||
|
||
# Check if there are uncommitted changes | ||
if ! git diff --quiet || ! git diff --cached --quiet; then | ||
echo "There are uncommitted changes. Please commit or stash them before running this script." | ||
exit 1 | ||
fi | ||
|
||
# Ensure that at least one commit argument is passed | ||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: $0 <commit1> <commit2> ... <commitN>" | ||
exit 1 | ||
fi | ||
|
||
commits=("$@") | ||
benchmarks_dir=benchmarks | ||
|
||
if ! mkdir -p "${benchmarks_dir}"; then | ||
echo "Unable to create dir for benchmarks data" | ||
exit 1 | ||
fi | ||
|
||
# Benchmark results | ||
bench_files=() | ||
|
||
# Run benchmark for each listed commit | ||
for i in "${!commits[@]}"; do | ||
commit="${commits[i]}" | ||
git checkout "$commit" || { | ||
echo "Failed to checkout $commit" | ||
exit 1 | ||
} | ||
|
||
# Sanitized commmit message | ||
commit_message=$(git log -1 --pretty=format:"%s" | tr -c '[:alnum:]-_' '_') | ||
|
||
# Benchmark data will go there | ||
bench_file="${benchmarks_dir}/${i}_${commit_message}.bench" | ||
|
||
if ! go test -bench=. -count=10 >"$bench_file"; then | ||
echo "Benchmarking failed for commit $commit" | ||
exit 1 | ||
fi | ||
|
||
bench_files+=("$bench_file") | ||
done | ||
|
||
# go install golang.org/x/perf/cmd/benchstat[@latest] | ||
benchstat "${bench_files[@]}" | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you prefix with a small comment:
# go install golang.org/x/perf/cmd/benchstat@latest