Re: [PATCH v7 43/59] perf sched-migration: Port sched-migration/SchedGui to use python module

sashiko-bot
2026-04-25T23:12:01Z

Sashiko AI review found 1 potential issue(s):
- [High] O(N) rendering loop causes severe UI freeze when scrolling past the end of the trace.
--

commit 07cc80943ab511e4ab9f7f60d5601a48a4f10e41
Author: Ian Rogers <irogers@google.com>

perf sched-migration: Port sched-migration/SchedGui to use python module

This commit refactors sched-migration.py to use a class structure and modern
directory layouts, porting it from tools/perf/scripts/python/.

> diff --git a/tools/perf/python/sched-migration.py b/tools/perf/python/sched-migration.py
> new file mode 100755
> index 000000000000..331278958763
> --- /dev/null
> +++ b/tools/perf/python/sched-migration.py

[ ... ]

> + def fill_zone(self, start: int, end: int):
> + """Fill zone in GUI."""
> + i = self.find_time_slice(start)
> + if i == -1:
> + i = 0
> +
> + for idx in range(i, len(self.data)):
> + timeslice = self.data[idx]
> + if timeslice.start > end:
> + return
> +
> + for cpu in timeslice.rqs:
> + self.update_rectangle_cpu(timeslice, cpu)

Can this loop cause a severe UI freeze when scrolling past the end of the
trace?

If the view is scrolled past the last recorded event, find_time_slice(start)
fails to find an enclosing timeslice and returns -1. However, the fallback
logic intercepts this and sets i = 0, causing the rendering loop to iterate
through every single recorded event in the entire trace.

Because the current view's end timestamp is strictly greater than all
recorded event timestamps, the early exit condition (timeslice.start > end)
is never met.

As a result, the GUI issues an update_rectangle_cpu call for every CPU of
every timeslice in the trace.

For traces containing millions of events, does this trigger millions of
off-screen draw calls on every paint event, freezing the application thread?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260425224951.174663-1-irogers@google.com?part=43