Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 1 | // Copyright (C) 2023 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use size file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Steve Golton | 5038846 | 2023-04-05 16:14:38 +0100 | [diff] [blame] | 15 | import m from 'mithril'; |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 16 | |
Steve Golton | 13dc3b6 | 2023-11-14 18:16:10 +0000 | [diff] [blame] | 17 | import {Time, time} from '../base/time'; |
Zim | 497e909 | 2023-08-01 02:09:18 +0100 | [diff] [blame] | 18 | import {runQuery} from '../common/queries'; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 19 | import {raf} from '../core/raf_scheduler'; |
Steve Golton | 6caf3c0 | 2023-09-07 08:09:06 +0100 | [diff] [blame] | 20 | import {Anchor} from '../widgets/anchor'; |
| 21 | import {Button} from '../widgets/button'; |
| 22 | import {DetailsShell} from '../widgets/details_shell'; |
Steve Golton | 6caf3c0 | 2023-09-07 08:09:06 +0100 | [diff] [blame] | 23 | import {GridLayout} from '../widgets/grid_layout'; |
| 24 | import {Section} from '../widgets/section'; |
| 25 | import {SqlRef} from '../widgets/sql_ref'; |
| 26 | import {Tree, TreeNode} from '../widgets/tree'; |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 27 | |
Steve Golton | 6559f9e | 2024-03-22 12:32:27 +0000 | [diff] [blame] | 28 | import {BottomTab, NewBottomTabArgs} from './bottom_tab'; |
Steve Golton | b3a389d | 2023-07-10 11:03:17 +0100 | [diff] [blame] | 29 | import {SchedSqlId, ThreadStateSqlId} from './sql_types'; |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 30 | import { |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 31 | getFullThreadName, |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 32 | getProcessName, |
| 33 | getThreadName, |
| 34 | ThreadInfo, |
| 35 | } from './thread_and_process_info'; |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 36 | import { |
| 37 | getThreadState, |
| 38 | getThreadStateFromConstraints, |
| 39 | goToSchedSlice, |
| 40 | ThreadState, |
| 41 | ThreadStateRef, |
| 42 | } from './thread_state'; |
Steve Golton | 13dc3b6 | 2023-11-14 18:16:10 +0000 | [diff] [blame] | 43 | import {DurationWidget, renderDuration} from './widgets/duration'; |
Steve Golton | 9248aed | 2023-06-01 15:20:01 +0100 | [diff] [blame] | 44 | import {Timestamp} from './widgets/timestamp'; |
Steve Golton | 6fc2bdc | 2024-01-25 16:56:22 +0000 | [diff] [blame] | 45 | import {addDebugSliceTrack} from './debug_tracks'; |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 46 | |
| 47 | interface ThreadStateTabConfig { |
| 48 | // Id into |thread_state| sql table. |
| 49 | readonly id: ThreadStateSqlId; |
| 50 | } |
| 51 | |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 52 | interface RelatedThreadStates { |
| 53 | prev?: ThreadState; |
| 54 | next?: ThreadState; |
| 55 | waker?: ThreadState; |
| 56 | wakee?: ThreadState[]; |
| 57 | } |
| 58 | |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 59 | export class ThreadStateTab extends BottomTab<ThreadStateTabConfig> { |
Hector Dearman | d3ccdc8 | 2023-06-19 14:34:14 +0100 | [diff] [blame] | 60 | static readonly kind = 'dev.perfetto.ThreadStateTab'; |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 61 | |
| 62 | state?: ThreadState; |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 63 | relatedStates?: RelatedThreadStates; |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 64 | loaded: boolean = false; |
| 65 | |
Steve Golton | c4115e8 | 2024-01-19 16:02:05 +0000 | [diff] [blame] | 66 | static create(args: NewBottomTabArgs<ThreadStateTabConfig>): ThreadStateTab { |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 67 | return new ThreadStateTab(args); |
| 68 | } |
| 69 | |
Steve Golton | c4115e8 | 2024-01-19 16:02:05 +0000 | [diff] [blame] | 70 | constructor(args: NewBottomTabArgs<ThreadStateTabConfig>) { |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 71 | super(args); |
| 72 | |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 73 | this.load().then(() => { |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 74 | this.loaded = true; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 75 | raf.scheduleFullRedraw(); |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 76 | }); |
| 77 | } |
| 78 | |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 79 | async load() { |
| 80 | this.state = await getThreadState(this.engine, this.config.id); |
| 81 | |
| 82 | if (!this.state) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | const relatedStates: RelatedThreadStates = {}; |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 87 | relatedStates.prev = ( |
| 88 | await getThreadStateFromConstraints(this.engine, { |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 89 | filters: [ |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 90 | `ts + dur = ${this.state.ts}`, |
| 91 | `utid = ${this.state.thread?.utid}`, |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 92 | ], |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 93 | limit: 1, |
| 94 | }) |
| 95 | )[0]; |
| 96 | relatedStates.next = ( |
| 97 | await getThreadStateFromConstraints(this.engine, { |
| 98 | filters: [ |
| 99 | `ts = ${this.state.ts + this.state.dur}`, |
| 100 | `utid = ${this.state.thread?.utid}`, |
| 101 | ], |
| 102 | limit: 1, |
| 103 | }) |
| 104 | )[0]; |
| 105 | if (this.state.wakerThread?.utid !== undefined) { |
| 106 | relatedStates.waker = ( |
| 107 | await getThreadStateFromConstraints(this.engine, { |
| 108 | filters: [ |
| 109 | `utid = ${this.state.wakerThread?.utid}`, |
| 110 | `ts <= ${this.state.ts}`, |
| 111 | `ts + dur >= ${this.state.ts}`, |
| 112 | ], |
| 113 | }) |
| 114 | )[0]; |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 115 | } |
| 116 | relatedStates.wakee = await getThreadStateFromConstraints(this.engine, { |
| 117 | filters: [ |
| 118 | `waker_utid = ${this.state.thread?.utid}`, |
| 119 | `state = 'R'`, |
| 120 | `ts >= ${this.state.ts}`, |
| 121 | `ts <= ${this.state.ts + this.state.dur}`, |
| 122 | ], |
| 123 | }); |
| 124 | |
| 125 | this.relatedStates = relatedStates; |
| 126 | } |
| 127 | |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 128 | getTitle() { |
| 129 | // TODO(altimin): Support dynamic titles here. |
| 130 | return 'Current Selection'; |
| 131 | } |
| 132 | |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 133 | viewTab() { |
| 134 | // TODO(altimin/stevegolton): Differentiate between "Current Selection" and |
| 135 | // "Pinned" views in DetailsShell. |
| 136 | return m( |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 137 | DetailsShell, |
| 138 | {title: 'Thread State', description: this.renderLoadingText()}, |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 139 | m( |
| 140 | GridLayout, |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 141 | m( |
| 142 | Section, |
| 143 | {title: 'Details'}, |
| 144 | this.state && this.renderTree(this.state), |
| 145 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 146 | m( |
| 147 | Section, |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 148 | {title: 'Related thread states'}, |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 149 | this.renderRelatedThreadStates(), |
| 150 | ), |
| 151 | ), |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 152 | ); |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 155 | private renderLoadingText() { |
| 156 | if (!this.loaded) { |
| 157 | return 'Loading'; |
| 158 | } |
| 159 | if (!this.state) { |
| 160 | return `Thread state ${this.config.id} does not exist`; |
| 161 | } |
| 162 | // TODO(stevegolton): Return something intelligent here. |
| 163 | return this.config.id; |
| 164 | } |
| 165 | |
| 166 | private renderTree(state: ThreadState) { |
| 167 | const thread = state.thread; |
| 168 | const process = state.thread?.process; |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 169 | return m( |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 170 | Tree, |
| 171 | m(TreeNode, { |
| 172 | left: 'Start time', |
| 173 | right: m(Timestamp, {ts: state.ts}), |
| 174 | }), |
| 175 | m(TreeNode, { |
| 176 | left: 'Duration', |
| 177 | right: m(DurationWidget, {dur: state.dur}), |
| 178 | }), |
| 179 | m(TreeNode, { |
| 180 | left: 'State', |
| 181 | right: this.renderState( |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 182 | state.state, |
| 183 | state.cpu, |
| 184 | state.schedSqlId, |
| 185 | state.ts, |
| 186 | ), |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 187 | }), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 188 | state.blockedFunction && |
| 189 | m(TreeNode, { |
| 190 | left: 'Blocked function', |
| 191 | right: state.blockedFunction, |
| 192 | }), |
| 193 | process && |
| 194 | m(TreeNode, { |
| 195 | left: 'Process', |
| 196 | right: getProcessName(process), |
| 197 | }), |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 198 | thread && m(TreeNode, {left: 'Thread', right: getThreadName(thread)}), |
| 199 | state.wakerThread && this.renderWakerThread(state.wakerThread), |
| 200 | m(TreeNode, { |
| 201 | left: 'SQL ID', |
| 202 | right: m(SqlRef, {table: 'thread_state', id: state.threadStateSqlId}), |
| 203 | }), |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 204 | ); |
| 205 | } |
| 206 | |
| 207 | private renderState( |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 208 | state: string, |
| 209 | cpu: number | undefined, |
| 210 | id: SchedSqlId | undefined, |
| 211 | ts: time, |
| 212 | ): m.Children { |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 213 | if (!state) { |
| 214 | return null; |
| 215 | } |
| 216 | if (id === undefined || cpu === undefined) { |
| 217 | return state; |
| 218 | } |
| 219 | return m( |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 220 | Anchor, |
| 221 | { |
| 222 | title: 'Go to CPU slice', |
| 223 | icon: 'call_made', |
| 224 | onclick: () => goToSchedSlice(cpu, id, ts), |
| 225 | }, |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 226 | `${state} on CPU ${cpu}`, |
| 227 | ); |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | private renderWakerThread(wakerThread: ThreadInfo) { |
| 231 | return m( |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 232 | TreeNode, |
| 233 | {left: 'Waker'}, |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 234 | m(TreeNode, { |
| 235 | left: 'Process', |
| 236 | right: getProcessName(wakerThread.process), |
| 237 | }), |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 238 | m(TreeNode, {left: 'Thread', right: getThreadName(wakerThread)}), |
Steve Golton | ca6f431 | 2023-06-01 07:03:05 +0000 | [diff] [blame] | 239 | ); |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 242 | private renderRelatedThreadStates(): m.Children { |
| 243 | if (this.state === undefined || this.relatedStates === undefined) { |
| 244 | return 'Loading'; |
| 245 | } |
| 246 | const startTs = this.state.ts; |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 247 | const renderRef = (state: ThreadState, name?: string) => |
| 248 | m(ThreadStateRef, { |
| 249 | id: state.threadStateSqlId, |
| 250 | ts: state.ts, |
| 251 | dur: state.dur, |
| 252 | utid: state.thread!.utid, |
| 253 | name, |
| 254 | }); |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 255 | |
| 256 | const sliceColumns = {ts: 'ts', dur: 'dur', name: 'name'}; |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 257 | const sliceColumnNames = ['id', 'utid', 'ts', 'dur', 'name', 'table_name']; |
Zim | 51b77c0 | 2023-08-04 16:49:24 +0100 | [diff] [blame] | 258 | |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 259 | const sliceLiteColumns = {ts: 'ts', dur: 'dur', name: 'thread_name'}; |
| 260 | const sliceLiteColumnNames = [ |
Zim | 51b77c0 | 2023-08-04 16:49:24 +0100 | [diff] [blame] | 261 | 'id', |
| 262 | 'utid', |
Zim | 51b77c0 | 2023-08-04 16:49:24 +0100 | [diff] [blame] | 263 | 'ts', |
| 264 | 'dur', |
Zim | 51b77c0 | 2023-08-04 16:49:24 +0100 | [diff] [blame] | 265 | 'thread_name', |
| 266 | 'process_name', |
Zim | 51b77c0 | 2023-08-04 16:49:24 +0100 | [diff] [blame] | 267 | 'table_name', |
| 268 | ]; |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 269 | |
| 270 | const nameForNextOrPrev = (state: ThreadState) => |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 271 | `${state.state} for ${renderDuration(state.dur)}`; |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 272 | return [ |
| 273 | m( |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 274 | Tree, |
| 275 | this.relatedStates.waker && |
| 276 | m(TreeNode, { |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 277 | left: 'Waker', |
| 278 | right: renderRef( |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 279 | this.relatedStates.waker, |
| 280 | getFullThreadName(this.relatedStates.waker.thread), |
| 281 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 282 | }), |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 283 | this.relatedStates.prev && |
| 284 | m(TreeNode, { |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 285 | left: 'Previous state', |
| 286 | right: renderRef( |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 287 | this.relatedStates.prev, |
| 288 | nameForNextOrPrev(this.relatedStates.prev), |
| 289 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 290 | }), |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 291 | this.relatedStates.next && |
| 292 | m(TreeNode, { |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 293 | left: 'Next state', |
| 294 | right: renderRef( |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 295 | this.relatedStates.next, |
| 296 | nameForNextOrPrev(this.relatedStates.next), |
| 297 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 298 | }), |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 299 | this.relatedStates.wakee && |
| 300 | this.relatedStates.wakee.length > 0 && |
| 301 | m( |
| 302 | TreeNode, |
| 303 | { |
| 304 | left: 'Woken threads', |
| 305 | }, |
| 306 | this.relatedStates.wakee.map((state) => |
| 307 | m(TreeNode, { |
| 308 | left: m(Timestamp, { |
| 309 | ts: state.ts, |
| 310 | display: [ |
| 311 | 'Start+', |
| 312 | m(DurationWidget, {dur: Time.sub(state.ts, startTs)}), |
| 313 | ], |
| 314 | }), |
| 315 | right: renderRef(state, getFullThreadName(state.thread)), |
| 316 | }), |
| 317 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 318 | ), |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 319 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 320 | m(Button, { |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 321 | label: 'Critical path lite', |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 322 | onclick: () => |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 323 | runQuery( |
| 324 | `INCLUDE PERFETTO MODULE sched.thread_executing_span;`, |
| 325 | this.engine, |
| 326 | ).then(() => |
| 327 | addDebugSliceTrack( |
| 328 | this.engine, |
| 329 | { |
| 330 | sqlSource: ` |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 331 | SELECT |
| 332 | cr.id, |
| 333 | cr.utid, |
| 334 | cr.ts, |
| 335 | cr.dur, |
| 336 | thread.name AS thread_name, |
| 337 | process.name AS process_name, |
| 338 | 'thread_state' AS table_name |
| 339 | FROM |
Lalit Maganti | 3e16bfd | 2024-01-30 23:06:26 +0000 | [diff] [blame] | 340 | _thread_executing_span_critical_path( |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 341 | ${this.state?.thread?.utid}, |
| 342 | trace_bounds.start_ts, |
Zim | 7e5df7f | 2023-11-13 23:23:31 +0000 | [diff] [blame] | 343 | trace_bounds.end_ts - trace_bounds.start_ts) cr, |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 344 | trace_bounds |
| 345 | JOIN thread USING(utid) |
| 346 | JOIN process USING(upid) |
| 347 | `, |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 348 | columns: sliceLiteColumnNames, |
| 349 | }, |
| 350 | `${this.state?.thread?.name}`, |
| 351 | sliceLiteColumns, |
| 352 | sliceLiteColumnNames, |
| 353 | ), |
| 354 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 355 | }), |
| 356 | m(Button, { |
Steve Golton | 5dbacf5 | 2024-01-25 09:20:51 +0000 | [diff] [blame] | 357 | label: 'Critical path', |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 358 | onclick: () => |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 359 | runQuery( |
| 360 | `INCLUDE PERFETTO MODULE sched.thread_executing_span_with_slice;`, |
| 361 | this.engine, |
| 362 | ).then(() => |
| 363 | addDebugSliceTrack( |
| 364 | this.engine, |
| 365 | { |
| 366 | sqlSource: ` |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 367 | SELECT cr.id, cr.utid, cr.ts, cr.dur, cr.name, cr.table_name |
| 368 | FROM |
Lalit Maganti | 3e16bfd | 2024-01-30 23:06:26 +0000 | [diff] [blame] | 369 | _thread_executing_span_critical_path_stack( |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 370 | ${this.state?.thread?.utid}, |
| 371 | trace_bounds.start_ts, |
Zim | 7e5df7f | 2023-11-13 23:23:31 +0000 | [diff] [blame] | 372 | trace_bounds.end_ts - trace_bounds.start_ts) cr, |
Zim | 56f67dc | 2023-08-27 01:50:30 +0100 | [diff] [blame] | 373 | trace_bounds WHERE name IS NOT NULL |
Zim | 497e909 | 2023-08-01 02:09:18 +0100 | [diff] [blame] | 374 | `, |
Lalit Maganti | 52826e8 | 2024-04-02 14:16:12 +0100 | [diff] [blame] | 375 | columns: sliceColumnNames, |
| 376 | }, |
| 377 | `${this.state?.thread?.name}`, |
| 378 | sliceColumns, |
| 379 | sliceColumnNames, |
| 380 | ), |
| 381 | ), |
Steve Golton | 7e63f42 | 2024-03-18 14:17:32 +0000 | [diff] [blame] | 382 | }), |
| 383 | ]; |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 384 | } |
| 385 | |
Alexander Timin | 00035a0 | 2023-03-17 15:32:45 +0000 | [diff] [blame] | 386 | isLoading() { |
Alexander Timin | 9075a35 | 2023-06-19 18:26:48 +0100 | [diff] [blame] | 387 | return this.state === undefined || this.relatedStates === undefined; |
Alexander Timin | 00035a0 | 2023-03-17 15:32:45 +0000 | [diff] [blame] | 388 | } |
Alexander Timin | 332f29a | 2023-02-21 17:48:05 +0000 | [diff] [blame] | 389 | } |