Skip to content

Add benchmark test for version.String() - #159

Merged
radeksimko merged 2 commits into
hashicorp:mainfrom
Manikkumar1988:benchmark_version_string
Jul 7, 2025
Merged

Add benchmark test for version.String()#159
radeksimko merged 2 commits into
hashicorp:mainfrom
Manikkumar1988:benchmark_version_string

Conversation

@Manikkumar1988

Copy link
Copy Markdown
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

hashicorp-cla-app Bot commented Jul 3, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@radeksimko radeksimko left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

Yes expectations is to bring down allocations to zero

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