When is it safe to read the .nsys-rep file created by nsys profile?

Since the .nsys-rep file(s) are written by nsys outside of the Python execution, I’m wondering if the creation and writing of the contents is “atomic” from the Python-perspective.

For example, if I’m running nsys profile with –-capture-range-end="stop", is the call to end_range blocking until the trace file is created? And thus, are the full contents of the file written to disk and flushed before returning from the end_range call? Or do I need to have a “watchdog” that e.g. checks if the file size is still changing?

Thanks!

I’m going to have @liuyis confirm, but my understanding is that while Nsight Systems is busy with the writing of the file, the application is allowed to continue forward.

We are working on improvements that would allow the user to decide if they want the resolution and permanent file generation to be done at the end of the range or at the end of the run.

With –-capture-range-end=stop, yes, the nsys-rep file is ready to be read when the thread returns from end_range.

With --capture-range-end=repeat[:N][:mode], the :mode needs to be set to :sync to ensure so.

You can check the help message for –-capture-range-end= switch from nsys profile –-help for more details.