Skip to content

Commit 8920f2f

Browse files
committed
profiling(gecko): take last thread as main thread instead of first one
The ordering is actually newest -> oldest, since the _remote_debugging code traverses the ThreadState linked list in the intepreter state, appending to a list of threads in-order. Signed-off-by: Sofia Donato Ferreira <flowlnlnln@gmail.com>
1 parent 4a82ac9 commit 8920f2f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Lib/profiling/sampling/gecko_collector.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,16 @@ def collect(self, stack_frames, timestamps_us=None):
170170
self.last_sample_time = times[-1]
171171

172172
# Process threads
173-
main_tid = None
174173
for interpreter_info in stack_frames:
174+
# Since 'threads' is in order from newest to oldest,
175+
# we know the first thread must be the main thread.
176+
main_tid = interpreter_info.threads[-1].thread_id
175177
for thread_info in interpreter_info.threads:
176178
frames = filter_internal_frames(thread_info.frame_info)
177179
tid = thread_info.thread_id
178180

179181
# Initialize thread if needed
180182
if tid not in self.threads:
181-
# Since 'threads' is in order from oldest to newest,
182-
# we know the first thread must be the main thread.
183-
if len(self.threads) == 0:
184-
main_tid = tid
185183
self.threads[tid] = self._create_thread(tid, main_tid)
186184

187185
thread_data = self.threads[tid]

0 commit comments

Comments
 (0)