Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Modify ChromeTracingWriter to generate traceEvents only once #14633

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

ys44kim
Copy link
Contributor

@ys44kim ys44kim commented Feb 11, 2025

This commit ensures that traceEvents is generated only once and prevents the error of generating multiple traceEvents when using multiple nnfw sessions.

ONE-DCO-1.0-Signed-off-by: youngsik kim [email protected]

This commit ensures that `traceEvents` is generated only once and prevents the error of generating multiple `traceEvents` when using multiple nnfw sessions.

ONE-DCO-1.0-Signed-off-by: youngsik kim <[email protected]>

void ChromeTracingWriter::flush(const std::vector<std::unique_ptr<EventRecorder>> &recorders)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using multiple sessions, the traceEvents is created every time flush is called, which may cause parsing errors in the Chrome Tracing JSON file.
to fix this issue, traceEvents is added only when creating the ChromeTracingWriter, not when flush is called.

Copy link
Contributor

Choose a reason for hiding this comment

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

ChromTracingWriter is destructed when process is finished because ChromTracingWriter is owned by EventWriter, and EventWriter is singleton object.
By this change, timing of file writing is changed from session closing to process exit.
IMHO, we need to decide more well-designed policy, including all event recorders, writers, and observers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with your opinion.
It would be better to discuss how to handle multiple sessions in the future.
Thank you.

@@ -38,6 +38,8 @@ void EventWriter::readyToFlush(std::unique_ptr<EventRecorder> &&recorder)
flush(WriteFormat::SNPE_BENCHMARK);
flush(WriteFormat::CHROME_TRACING);
flush(WriteFormat::MD_TABLE);

_recorders.clear();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clear the contents of the vector to prevent duplicate recorders.

@ys44kim ys44kim requested a review from a team February 11, 2025 07:13
Copy link
Contributor

@seockho-kim seockho-kim left a comment

Choose a reason for hiding this comment

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

LGTM

@hseok-oh hseok-oh self-requested a review February 11, 2025 08:59
@ys44kim
Copy link
Contributor Author

ys44kim commented Feb 11, 2025

As discussed with @hseok-oh,
we need to decide how to handle trace files with multiple sessions.
I think there are two options:

  1. Append traceEvents to a single trace file (current approach)
  2. Create a separate trace file for each session

I think it would be better to append traceEvents to a single trace file (option.1)
because, we can avoid the issue of creating multiple traceEvents when using multiple sessions, and we can view multiple circles(session) in a single view by merging the trace files.

Copy link
Contributor

@hseok-oh hseok-oh left a comment

Choose a reason for hiding this comment

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

Anyway, I'll approve this PR to resolve bug.

Copy link
Contributor

@hseok-oh hseok-oh left a comment

Choose a reason for hiding this comment

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

LGTM

@hseok-oh hseok-oh merged commit 6527e1c into Samsung:master Feb 11, 2025
18 checks passed
@ys44kim ys44kim deleted the onert/trace_250210 branch February 12, 2025 01:16
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