Skip to content

Fix event skipping in the timeline viewer #116

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

Merged
merged 2 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lglpy/timeline/data/processed_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
# Common data we get from the layer metadata
self.submit = None
self.label_stack = None
self.parsed_label_name = None
self.parsed_label_name: Optional[str] = None

if metadata:
self.submit = metadata.submit
Expand Down
18 changes: 13 additions & 5 deletions lglpy/timeline/data/raw_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,13 @@ def load_perfetto_from_file(
# Sort events into time order
trace_events.sort(key=lambda x: x.start_time)

# Replace all interned data cross-references to assign real stream
# names before trying to use streams because we may get more than one
# interned ID for the same physical stream and this will dedupe them
for event in trace_events:
config.replace_interned_stream(event)
config.replace_interned_stage(event)

# Replace time so first event starts at time = 0 and that queued time
# waiting for earlier work does not show as running
streams = {}
Expand All @@ -893,18 +900,19 @@ def load_perfetto_from_file(
# Later job in stream so remove any overlap with job N-1
last_event = streams[event.stream][-1]
last_event_end = last_event.start_time + last_event.duration
streams[event.stream].append(event)

# Remove overlap if queued while last event still running
if event.start_time <= last_event_end:
time_diff = last_event_end - event.start_time + 1
event.start_time += time_diff
event.duration -= time_diff

# Replace all interned data cross-references
for event in trace_events:
config.replace_interned_stream(event)
config.replace_interned_stage(event)
# Ensure we don't have negative duration events
if event.duration <= 0:
event.duration = 1

# Add event to the stream after patching it
streams[event.stream].append(event)

return (trace_events, start_time)

Expand Down