Skip to content

performance: Decouple segment construction from OfflineWriter.Batch locking#149

Open
shoriwe wants to merge 9 commits intoblugelabs:masterfrom
pluto-org-co:master
Open

performance: Decouple segment construction from OfflineWriter.Batch locking#149
shoriwe wants to merge 9 commits intoblugelabs:masterfrom
pluto-org-co:master

Conversation

@shoriwe
Copy link
Copy Markdown

@shoriwe shoriwe commented Mar 16, 2026

Reference issue

#148

Comment thread index/writer_offline.go
Comment on lines -60 to -62
s.m.Lock()
defer s.m.Unlock()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

With this change caller can go directly to Analyze, segment and persist the changes as soon as possible. Instead of waiting for the entire function to finish

Comment thread index/writer_offline.go
Comment on lines +83 to +85
s.m.Lock()
s.segIDs = append(s.segIDs, newId)
s.m.Unlock()
Copy link
Copy Markdown
Author

@shoriwe shoriwe Mar 16, 2026

Choose a reason for hiding this comment

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

This is the only thread unsafe part of the code, since slices can't be appended concurrently

Comment thread index/writer_offline.go
Comment on lines +76 to +78
newId := s.segCount.Add(1)
// There is zero chance of collision we can safely use the computed id
err = s.directory.Persist(ItemKindSegment, newId, newSegment, nil)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Once the new segment id is computed, the persist function should respect any subsequent segment

@shoriwe
Copy link
Copy Markdown
Author

shoriwe commented Mar 16, 2026

Added some description to the why of the changes. Looking forward for a review

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.

1 participant