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

test: add benchmarks #54

Merged
merged 2 commits into from
Oct 19, 2021
Merged

test: add benchmarks #54

merged 2 commits into from
Oct 19, 2021

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Oct 14, 2021

Adds benchmarks that compare the performance of the go-sql driver with the normal Spanner client.

Executing the benchmarks on a VM on Google Cloud that is physically close to the database that is being tested yields the following results:

Benchmark go-sql Client
SelectSingleRecord 8027885 ns/op 7605408 ns/op
SelectAndUpdateUsingMutation 16588398 ns/op 15454486 ns/op
SelectAndUpdateUsingDml 20143182 ns/op 21006488 ns/op
CreateAndReload 16834755 ns/op 16987523 ns/op
CreateAlbumsUsingMutations. 22605913 ns/op 23259244 ns/op
Select100Singers 92737263 ns/op 94163536 ns/op
Select100SingersInReadOnlyTx 96486050 ns/op 96695674 ns/op
Select100SingersInReadWriteTx 130437345 ns/op 124886457 ns/op

Closes #33

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 14, 2021
@hengfengli
Copy link
Collaborator

hengfengli commented Oct 19, 2021

@olavloite Does this mean that the performance of go-sql driver is pretty similar to directly using client library? They look very close and there is no big difference.

Copy link
Collaborator

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

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

LGTM.

@olavloite
Copy link
Collaborator Author

@olavloite Does this mean that the performance of go-sql driver is pretty similar to directly using client library? They look very close and there is no big difference.

Yes, that is correct. The Go sql driver is in most cases a relatively thin layer on top of the client library, so that is also as expected. The only scenario where there is a measurable difference is when selecting a larger result set in a read/write transaction, as the Go sql driver will then keep track of a running checksum of the results that it sees.

@olavloite olavloite merged commit 01828bb into main Oct 19, 2021
@olavloite olavloite deleted the benchmarks branch October 19, 2021 05:39
@rahul2393
Copy link
Collaborator

Fresh run

Benchmark go-sql Client
SelectSingleRecord 7256458 ns/op 6365998 ns/op
SelectAndUpdateUsingMutation 35894568 ns/op 30139076 ns/op
SelectAndUpdateUsingDml 32422615 ns/op 21006488 ns/op
CreateAndReload 33583545 ns/op 24802121 ns/op
CreateAlbumsUsingMutations. 40948656 ns/op 45372519 ns/op
Select100Singers 42971542 ns/op 35908125 ns/op
Select100SingersInReadOnlyTx 39085144 ns/op 49537134 ns/op
Select100SingersInReadWriteTx 58363907 ns/op 45240976 ns/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Benchmarks
3 participants