Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use singleton for null telemetry objects in NullTelemetryFactory #1188

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

johnou
Copy link
Contributor

@johnou johnou commented Nov 12, 2024

Summary

While testing our application for regressions in performance after adopting aws-advanced-jdbc-wrapper we found a lot of useless allocations from the NullTelemetryFactory [1].

[1] Screenshot 2024-11-12 131311

Description

Refactored NullTelemetryFactory to use a singleton instance for NullTelemetryContext, TelemetryCounter, and TelemetryGauge, eliminating repeated object creation and reducing memory allocations.

I also considered using a caching approach but opted for the singleton pattern to further simplify the code and minimize memory churn. I verified software.amazon.jdbc.util.telemetry.NullTelemetryContext#getName is not used in any code paths.

Additional Reviewers

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sergiyvamz
Copy link
Contributor

Hi @johnou

Thank you for looking into that!

@sergiyvamz sergiyvamz merged commit 7016110 into aws:main Nov 13, 2024
5 checks passed
@johnou johnou deleted the singleton-null-telemetry branch November 14, 2024 07:28
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants