perf(spanner): only create sessions if multiplexed sessions are disabled#13477
perf(spanner): only create sessions if multiplexed sessions are disabled#13477
Conversation
Only create regular sessions if multiplexed sessions have not been enabled for all operations. If multiplexed sessions have been enabled for all operations, and the application has not set a custom number of minimum number of sessions, then the session pool will no longer create a default of 100 regular sessions. These then also do not need to be maintained by the pool.
Summary of ChangesHello @olavloite, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a performance enhancement for the Spanner client by optimizing session pool initialization. It intelligently prevents the creation of a default set of regular sessions when multiplexed sessions are fully active and the application hasn't explicitly configured a minimum session count, thereby reducing resource overhead and improving efficiency. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a performance optimization to prevent the creation of regular sessions when multiplexed sessions are enabled for all operations and the default minimum session count hasn't been customized. The logic is sound and the accompanying test changes improve robustness by removing hardcoded values. I have one suggestion to improve the readability of the new conditional logic in spanner/client.go.
8f8b238 to
70c9de6
Compare
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v1.0.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:19bb93e8f1f916c61b597db2bad65dc432f79baaabb210499d7d0e4ad1dffe29 <details><summary>spanner: 1.88.0</summary> ## [1.88.0](spanner/v1.87.0...spanner/v1.88.0) (2026-02-11) ### Features * Adding Send and Ack Mutation Support for Cloud Spanner Queue (#13616) ([1cf600d](1cf600d6)) * include cache updates into the ResultSet response (PiperOrigin-RevId: 865546011) ([6f31019](6f310199)) * add a ClientContext field to Spanner requests (PiperOrigin-RevId: 853323071) ([80379ed](80379edb)) * add Secure Parameters to the ClientContext (PiperOrigin-RevId: 853323071) ([80379ed](80379edb)) * PGNumeric implements Scanner and Valuer (#13722) ([85bc9db](85bc9dbf)) * support struct literal (#13766) ([b4a6f4c](b4a6f4c5)) * Exposing total CPU related fields in AutoscalingConfig (PiperOrigin-RevId: 845819318) ([db65e79](db65e792)) * add ClientContext support (#13775) ([e85d706](e85d7061)) ### Bug Fixes * disable config logging by default (#13478) ([ad19592](ad19592e)) * decode PG JSONB array to PGJsonB struct (#13602) ([d72d0f4](d72d0f45)) ### Performance Improvements * only create sessions if multiplexed sessions are disabled (#13477) ([e44e58f](e44e58f6)) ### Documentation * A comment for field `param_types` in message `.google.spanner.v1.PartitionQueryRequest` is changed (PiperOrigin-RevId: 865546011) ([6f31019](6f310199)) * A comment for field `transaction_tag` in message `.google.spanner.v1.RequestOptions` is changed (PiperOrigin-RevId: 865546011) ([6f31019](6f310199)) * A comment for field `commit_timestamp` in message `.google.spanner.v1.BatchWriteResponse` is changed (PiperOrigin-RevId: 865546011) ([6f31019](6f310199)) * A comment for field `params` in message `.google.spanner.v1.PartitionQueryRequest` is changed (PiperOrigin-RevId: 865546011) ([6f31019](6f310199)) * Update client side metrics and permission issues in README (#13491) ([ab56892](ab56892e)) * Update high_priority_cpu_utilization_percent in AutoscalingConfig to be Optional and clarify its behavior when not specified (PiperOrigin-RevId: 845819318) ([db65e79](db65e792)) </details>
Only create regular sessions if multiplexed sessions have not been enabled for all operations. If multiplexed sessions have been enabled for all operations, and the application has not set a custom number of minimum number of sessions, then the session pool will no longer create a default of 100 regular sessions. These then also do not need to be maintained by the pool.
This change will cause the session pool to contain 0 session by default. The session pool will only be initialized with a non-zero number of sessions if any of the following is true:
MinOpenedhas been set to a non-default value (meaning:MinOpened != 100)