Skip to content

Bytes implementation#161

Merged
radeksimko merged 3 commits intohashicorp:mainfrom
Manikkumar1988:bytes_implementation
Jul 16, 2025
Merged

Bytes implementation#161
radeksimko merged 3 commits intohashicorp:mainfrom
Manikkumar1988:bytes_implementation

Conversation

@Manikkumar1988
Copy link
Copy Markdown
Contributor

Description

Instead of using the strings package for construction version string, used the bytes[] which has drastically reduced the number of allocs/op and B/op

There is still room for improvement. More on here

Related Issue

#118

How Has This Been Tested?

With Bytes Implementation
image

With String Implementation
image

@Manikkumar1988 Manikkumar1988 requested a review from a team as a code owner July 8, 2025 17:18
Copy link
Copy Markdown
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.

Impressive improvement.

Having tinkered with this PR a bit, I'm assuming that big part of the memory allocations come from inside of bytes.Buffer. A bit unfortunate but I suppose that's the cost for the convenient API which we are now giving up here.

Aside from that mostly stylistic comment in-line this LGTM and I'd be happy to merge when that is addressed.


It would be interesting to see the impact of storing the parsed version parts as bytes also and only converting to strings when necessary - just an idea for another PR. 🤔

Comment thread version.go Outdated
@Manikkumar1988
Copy link
Copy Markdown
Contributor Author

Once this is merged, will raise an another PR with storing the parsed version parts as bytes array, definitely can reduce the number of allocs/op and B/op by then.

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

Thank you

@radeksimko radeksimko enabled auto-merge (squash) July 16, 2025 08:21
@radeksimko radeksimko merged commit 4e24ef1 into hashicorp:main Jul 16, 2025
1 check passed
@Manikkumar1988 Manikkumar1988 deleted the bytes_implementation branch July 16, 2025 13:45
@QuLogic QuLogic mentioned this pull request Jul 30, 2025
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