Skip to content

Conversation

@nickysn
Copy link
Collaborator

@nickysn nickysn commented Jul 15, 2025

This change still doesn't implement stream writing, yet. It just changes the API, so that future format implementations can support streaming transparently, without any changes to the users of the library.

nickysn added 29 commits July 12, 2025 01:38
It does not support streaming, yet.
…e_trace_events(). Instead, use the format, specified in the previous call to begin_writing_trace_events()
…trace_events(). Use the path, specified in the previous call to begin_writing_trace_events() instead
…ents is called without begin_writing_trace_events
…e_metadata; use the path, specified in the call to begin_writing_trace_metadata
…e_paths; use the path, specified in the call to begin_writing_trace_paths
impl TraceWriter for Tracer {
/// Begin tracing of a program starting at the given source location.
pub fn start(&mut self, path: &Path, line: Line) {
fn start(&mut self, path: &Path, line: Line) {
Copy link
Member

Choose a reason for hiding this comment

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

i didn't realize i don't need to add pub for pub trait method implementations before: nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Actually, when implementing a trait, using 'pub' is not allowed and produces a compiler error.

Copy link
Member

Choose a reason for hiding this comment

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

aha, makes sense

TraceEventsFileFormat::Binary => {
let mut file = fs::File::create(path)?;
crate::capnptrace::write_trace(&self.events, &mut file)?;
fn finish_writing_trace_events(&mut self) -> Result<(), Box<dyn Error>> {
Copy link
Member

@alehander92 alehander92 Jul 16, 2025

Choose a reason for hiding this comment

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

what would this method do for streaming writer in the future: just doing nothing, as everything is already streamed into the file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Depends on the file format. For simple file formats, it might be nothing, but for other formats it could also seek back to the header, update the events count, append an index at the end of the file, etc.

Copy link
Member

@alehander92 alehander92 Jul 16, 2025

Choose a reason for hiding this comment

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

i am asking, because e.g. if we want to start replay-s of partial records, while the recording is still running in the future, it might be good for the record to be always in "usable" form, but this is not something that's a priority now I think. (I remember @zah talking about this in the past)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an entirely independent feature. Adding finish_writing_trace_events() does not prevent us from implementing partial recording support. Even in that case, finish_writing_trace_events() can be useful, for marking the file as finished. And even it's implemented as no operation for some formats, so what? It only takes an extra nanosecond once per finished recording. The extra flexibility is worth it, even for the internal debug log capabilities, e.g. for answering the question "did the tracer crash, or finish successfully".

Copy link
Member

Choose a reason for hiding this comment

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

yes, i agree it's still useful! just wanted to make sure we can easily support partial records in the future: sounds good

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Partial recording will probably not work at the moment, since we're planning to use Zstd_seekable compression, and I don't think its compression format supports it. I'm not 100% sure about that, though. But that's an independent issue, not related to the API.

Copy link
Member

Choose a reason for hiding this comment

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

indeed

Copy link
Member

@alehander92 alehander92 left a comment

Choose a reason for hiding this comment

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

looks good!

@alehander92
Copy link
Member

can you just change the version of the lib to 0.13.0, as it's a breaking change

@alehander92
Copy link
Member

alehander92 commented Jul 16, 2025

on the other hand if we want to follow semver .. many of those should be actually updating the major number, but we wanted to wait before making a 1.X, so we haven't been semver purists until now anyway

@nickysn
Copy link
Collaborator Author

nickysn commented Jul 16, 2025

can you just change the version of the lib to 0.13.0, as it's a breaking change

Done.

@alehander92 alehander92 merged commit 36812d7 into master Jul 16, 2025
2 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.

3 participants