Skip to content
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

add compiler hints to reduce number of slice bounds checks #158

Merged
merged 2 commits into from
Sep 28, 2024

Conversation

NyaaaWhatsUpDoc
Copy link
Contributor

Just some quick changes that hint to the compiler expected lengths in places to reduce the number of slice bounds checks it needs to do. You can confirm before and after results by using -gcflags="-d=ssa/check_bce/debug=1", or more usefully i was specifically doing go test -gcflags="-d=ssa/check_bce/debug=1" -v 2>&1 1>/dev/null | grep $fileNameToCheck

@NyaaaWhatsUpDoc
Copy link
Contributor Author

in particular a good example of another use of the underscored slice value accessing is in binary.{LittleEndian,BigEndian}

Copy link
Owner

@ncruces ncruces left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great idea, and you covered some of the hot points.

Was it profile guided, should I look elsewhere?

Thanks!

stmt.go Outdated Show resolved Hide resolved
@NyaaaWhatsUpDoc
Copy link
Contributor Author

This looks like a great idea, and you covered some of the hot points.

Was it profile guided, should I look elsewhere?

Thanks!

i wish i could say it was anything as intelligent as having been directed by profile guided optimizations... it was more just i was bored, fiddling around, and noticed an opportunity for improvement :')

@ncruces
Copy link
Owner

ncruces commented Sep 28, 2024

The func.go ones can be really hot points, maybe not on “normal” usage (where callbacks are mostly used to read data from disk), but certainly if used in (e.g.) an aggregate function or collation sequence (where a callback may be called millions of times to sort a row set, or calculate statistics).

Columns is not that hot, but it's still almost single handedly responsible for this driver being close to as fast in queries as mattn.

@ncruces ncruces merged commit 3293103 into ncruces:main Sep 28, 2024
9 checks passed
@ncruces
Copy link
Owner

ncruces commented Sep 30, 2024

This lead to a 7% improvement on this benchmark.
Still lots of overhead, but every bit helps, so thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants