Skip to content

Conversation

@Manikkumar1988
Copy link
Contributor

Description

Benchmark Results:
image
Number of memory allocations per operation: 8 individual allocations per call to String()
This causes GC pressure and slowdowns when called in large volume systems.

If this function is called 1 million times, that’s 8 million allocations, which leads to OOM in our case.

Related Issue

#118

How Has This Been Tested?

Clone this branch and run
go test -bench=BenchmarkVersionString

@Manikkumar1988 Manikkumar1988 requested a review from a team as a code owner July 3, 2025 19:28
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Jul 3, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks, happy to merge this.

As far as I can tell, the expectation/hope is the bring all the allocations down to zero, since the benchmark measures 2nd and other subsequent String() calls, right?

@Manikkumar1988
Copy link
Contributor Author

Yes expectations is to bring down allocations to zero

@radeksimko radeksimko merged commit 437649a into hashicorp:main Jul 7, 2025
1 check passed
@Manikkumar1988 Manikkumar1988 deleted the benchmark_version_string branch July 7, 2025 13:06
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.

3 participants