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

fix: Avoid creating message string prematurely for streaming calls #3622

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

mina-asham
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, please read our contributing guidelines.

There are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #3621 ☕️

- Creating the string message prematurely puts a lot of strain on the JVM and GC, switch to the format version of `Preconditions.checkState` which only constructs the string if we throw the exception
- Issue: googleapis#3621
@lqiu96
Copy link
Contributor

lqiu96 commented Feb 10, 2025

/gcbrun

@lqiu96
Copy link
Contributor

lqiu96 commented Feb 10, 2025

Thanks for raising the issue and providing a fix. This does seem like an issue and we'll review this.

Could you update the title to follow conventional commits? Perhaps something like `fix: Avoid creating message string prematurely for streaming calls".

@mina-asham mina-asham changed the title Avoid creating error message string prematurely fix: Avoid creating error message string prematurely Feb 10, 2025
@mina-asham mina-asham changed the title fix: Avoid creating error message string prematurely fix: Avoid creating message string prematurely for streaming calls Feb 10, 2025
@mina-asham
Copy link
Contributor Author

Thanks @lqiu96, updated the title!

Copy link
Contributor

@lqiu96 lqiu96 left a comment

Choose a reason for hiding this comment

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

LGTM. @zhumin8 for a second opinion

I do see Guava's warnings about Preconditions here. I think these changes will help with performance, but if we continue to have performance issues, we can convert these Preconditions into if checks.

Copy link
Contributor

@zhumin8 zhumin8 left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.

@lqiu96 lqiu96 merged commit f805e70 into googleapis:main Feb 10, 2025
44 of 47 checks passed
lqiu96 pushed a commit that referenced this pull request Feb 10, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>2.53.0</summary>

##
[2.53.0](v2.52.0...v2.53.0)
(2025-02-10)


### Features

* enable DirectPath bound token in InstantiatingGrpcChannelProvider
([#3572](#3572))
([5080495](5080495))
* Enable MTLS_S2A bound token by default for gRPC S2A enabled flows
([#3591](#3591))
([81e21f2](81e21f2))
* migrate away from deprecated graal-sdk dependency to use nativeimage
([#2706](#2706))
([757801a](757801a))


### Bug Fixes

* Avoid creating message string prematurely for streaming calls
([#3622](#3622))
([f805e70](f805e70))


### Dependencies

* update dependency com.google.code.gson:gson to v2.12.0
([#3595](#3595))
([1f1b119](1f1b119))
* update dependency com.google.code.gson:gson to v2.12.0
([#3596](#3596))
([af62f53](af62f53))
* update dependency com.google.code.gson:gson to v2.12.1
([#3599](#3599))
([18917ee](18917ee))
* update dependency com.google.code.gson:gson to v2.12.1
([#3600](#3600))
([3f82836](3f82836))
* update dependency commons-codec:commons-codec to v1.18.0
([#3590](#3590))
([cd46ba5](cd46ba5))
* update dependency io.netty:netty-tcnative-boringssl-static to
v2.0.70.final
([#3623](#3623))
([a4d1f95](a4d1f95))
* update dependency lxml to v5.3.1
([#3624](#3624))
([5407646](5407646))
* update dependency net.bytebuddy:byte-buddy to v1.17.0
([#3582](#3582))
([54d99e9](54d99e9))
* update dependency org.checkerframework:checker-qual to v3.49.0
([#3604](#3604))
([390cffa](390cffa))
* update dependency org.graalvm.sdk:nativeimage to v24.1.2
([#3597](#3597))
([9d151c4](9d151c4))
* update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to 456f60c
([#3607](#3607))
([c2d2768](c2d2768))
* update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to d323c2b
([#3601](#3601))
([ed35c23](ed35c23))
* update docker.io/library/python docker tag to v3.13.2
([#3615](#3615))
([ba007c2](ba007c2))
* update docker.io/library/python:3.13.1-alpine3.20 docker digest to
7788ec8
([#3586](#3586))
([a24d1ba](a24d1ba))
* update google api dependencies
([#3584](#3584))
([08f2b7b](08f2b7b))
* update google auth library dependencies to v1.32.0
([#3611](#3611))
([9436eb0](9436eb0))
* update google auth library dependencies to v1.32.1
([#3618](#3618))
([88c78e2](88c78e2))
* update google http client dependencies to v1.46.1
([#3616](#3616))
([2462105](2462105))
* update googleapis/java-cloud-bom digest to 47ad868
([#3608](#3608))
([2bcf9e0](2bcf9e0))
* update googleapis/java-cloud-bom digest to 514a644
([#3602](#3602))
([172d4da](172d4da))
* update googleapis/java-cloud-bom digest to 7752ecd
([#3603](#3603))
([06be924](06be924))
* update netty dependencies to v4.1.117.final
([#3581](#3581))
([2734dc0](2734dc0))
* update netty dependencies to v4.1.118.final
([#3625](#3625))
([16ff6bd](16ff6bd))
* update netty dependencies to v4.1.118.final
([#3626](#3626))
([316c425](316c425))
* Update OpenTelemetry semantic convention packages in the shared
dependencies
([#3402](#3402))
([0e69784](0e69784))
* update opentelemetry-java monorepo to v1.46.0
([#3585](#3585))
([ac214be](ac214be))
* update opentelemetry-java monorepo to v1.47.0
([#3619](#3619))
([66901df](66901df))
* update repo-automation-bots digest to 35eff2c
([#3609](#3609))
([b962a01](b962a01))
* update repo-automation-bots digest to 3a68a9c
([#3620](#3620))
([1d79552](1d79552))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gax: Excessive byte[] allocations with large read stream requests
3 participants