Skip to content

instead of having constantly running thread, segment creator v2 spans…#98

Merged
generall merged 5 commits intomasterfrom
segment-creator-v2
Oct 16, 2025
Merged

instead of having constantly running thread, segment creator v2 spans…#98
generall merged 5 commits intomasterfrom
segment-creator-v2

Conversation

@generall
Copy link
Member

… threads on demand

Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

The thread scheduling we have here seems a bit complicated to me. But, I don't see any problems with it. I like that we now create a thread on demand.

It looks like we can hit a 'no segments available' error if we'd request new segments very fast, where the segment creator doesn't have time to actually create the segment on disk. I'd rather block here to just wait on the segment being created to eliminate this edge case.

Left a few review remarks, mostly nitpicks.

use std::path::{Path, PathBuf};
use std::thread;

pub struct SegmentCreatorV2 {
Copy link
Member

Choose a reason for hiding this comment

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

Shall we keep it SegmentCreator, and properly replace the old one?

segment_capacity: usize,
) -> std::io::Result<Vec<OpenSegment>> {
// Directory being a file only applies to Linux
#[cfg(not(target_os = "windows"))]
Copy link
Member

Choose a reason for hiding this comment

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

Shall we make it a bit more specific, like

Suggested change
#[cfg(not(target_os = "windows"))]
#[cfg(target_os = "linux")]

or

Suggested change
#[cfg(not(target_os = "windows"))]
#[cfg(target_family = "unix")]

}

#[cfg(not(target_os = "windows"))]
dir.sync_all()?;
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? Why not just sync the segment files itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, I just re-used existing logic

@generall generall merged commit 95c4310 into master Oct 16, 2025
4 checks passed
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