Skip to content

broker: fragment list Pathpostfix interning#464

Merged
williamhbaker merged 1 commit intomasterfrom
wb/mem-2
Mar 24, 2026
Merged

broker: fragment list Pathpostfix interning#464
williamhbaker merged 1 commit intomasterfrom
wb/mem-2

Conversation

@williamhbaker
Copy link
Copy Markdown
Contributor

Fragment listings include the PathPostfix for every fragment. This had been constructed by a couple of string slices: (1) In (*store).List implementations by a strings.TrimPrefix, and (2) in ParseFragmentFromRelativePath by path.Dir.

Taking a slice of a string causes the underlying string to be retained in memory, and this effect is significant if the postfix is relatively short compared to the full fragment path. Additionally, there is often a high degree of overlap in the postfix across journals.

This change uses unique to canonicalize the Pathpostfix across fragments to address both of these inefficiencies. The original backing strings will no longer be retained in memory, and only a single full postfix will be retained for every unique occurrence.

Fragment listings include the PathPostfix for every fragment. This had
been constructed by a couple of string slices: (1) In `(*store).List`
implementations by a `strings.TrimPrefix`, and (2) in
`ParseFragmentFromRelativePath` by `path.Dir`.

Taking a slice of a string causes the underlying string to be retained
in memory, and this effect is significant if the postfix is relatively
short compared to the full fragment path. Additionally, there is often a
high degree of overlap in the postfix across journals.

This change uses `unique` to canonicalize the Pathpostfix across
fragments to address both of these inefficiencies. The original backing
strings will no longer be retained in memory, and only a single full
postfix will be retained for every unique occurrence.
Copy link
Copy Markdown
Contributor

@jgraettinger jgraettinger left a comment

Choose a reason for hiding this comment

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

LGTM!

@williamhbaker williamhbaker merged commit 2dcccb3 into master Mar 24, 2026
1 check passed
@williamhbaker williamhbaker deleted the wb/mem-2 branch March 24, 2026 14:48
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