Skip to content

tp: interval_intersect: add k-pointer sweep for non-overlapping tables - #7619

Draft
wusamuel6 wants to merge 2 commits into
mainfrom
dev/wusamuel/ii_optimize
Draft

wusamuel6 wants to merge 2 commits into
mainfrom
dev/wusamuel/ii_optimize

Conversation

@wusamuel6

Copy link
Copy Markdown
Contributor

Add PushPartitionNonOverlapping to construct intervals using k-pointers
approach, improving runtime from O(knlog(n)) time and O(n) memory to
O(k*n) time and O(1) extra memory, where k is number of tables and n the
total number of input intervals.

This approach only works if all intervals being intersected are
non-overlapping, and the overlapping intervals fallback to current
algorithm with a tree. AFAICT, in practice, quite a few intervals are
non-overlapping (e.g. cpu_freq, cpu_idle, sched, etc.).

Speedup results:

  • Wattson 11-way intersect (wattson_tk4_pcmark.pb 32s): 205ms -> 124ms (1.65x)
  • ii(cpu0_freq, cpu0_idle) (Fitbit_2.pb 40min): 175ms -> 134ms (1.23x)

Bug: 354290668

…ng()

Step() marked a partition as non-overlapping by checking each start
against the previous end. That misses an instant at t followed by
another row at t (a second instant, or an interval starting at t), which
IsOverlapping() treats as overlapping.

So unify places that need to check for overlapping while accounting for
instants with a single source of truth, IsOverlapping().
Add PushPartitionNonOverlapping to construct intervals using k-pointers
approach, improving runtime from O(k*n*log(n)) time and O(n) memory to
O(k*n) time and O(1) extra memory, where k is number of tables and n the
total number of input intervals.

This approach only works if all intervals being intersected are
non-overlapping, and the overlapping intervals fallback to current
algorithm with a tree. AFAICT, in practice, quite a few intervals are
non-overlapping (e.g. cpu_freq, cpu_idle, sched, etc.).

Speedup results:
- Wattson 11-way intersect (wattson_tk4_pcmark.pb 32s): 205ms -> 124ms (1.65x)
- ii(cpu0_freq, cpu0_idle) (Fitbit_2.pb 40min): 175ms -> 134ms (1.23x)

Bug: 354290668
@github-actions

Copy link
Copy Markdown

🎨 Perfetto UI Builds & Tests

This branch has not been deployed

No deployments
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.

1 participant