Skip to content

Reduce memory allocations and improve longestUnique performance#1199

Merged
egibs merged 1 commit into
chainguard-dev:mainfrom
egibs:perf-allocation-improvements
Nov 4, 2025
Merged

Reduce memory allocations and improve longestUnique performance#1199
egibs merged 1 commit into
chainguard-dev:mainfrom
egibs:perf-allocation-improvements

Conversation

@egibs

@egibs egibs commented Nov 3, 2025

Copy link
Copy Markdown
Member

This PR contains a few memory allocation improvements (usage of strings.Builder) and also makes longestUnique both ~more correct and also 2-3x faster on average. While still O(n^2), we only work on a smaller, unique slice of strings and use less memory to do so.

@egibs egibs requested a review from antitree November 3, 2025 20:46
@egibs egibs force-pushed the perf-allocation-improvements branch 5 times, most recently from 3ec6402 to 9030073 Compare November 3, 2025 21:40
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
@egibs egibs force-pushed the perf-allocation-improvements branch from 9030073 to 91961ea Compare November 3, 2025 21:54
@egibs egibs merged commit 8c3e803 into chainguard-dev:main Nov 4, 2025
13 checks passed
@egibs egibs deleted the perf-allocation-improvements branch November 4, 2025 14:54
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.

2 participants