diff options
author | Steve Golton <stevegolton@google.com> | 2024-05-14 18:33:37 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-14 18:33:37 +0000 |
commit | 2b4e9309d3a6a59d918416e5554449144acc10d5 (patch) | |
tree | acd78dfd42d7333347326573de64452d6bf91eb7 /ui | |
parent | cbbd2b57bb6e465deb4a203abcd98d0e33869aa4 (diff) | |
parent | a23865afdb41c17a3bdbf23bc8e306b7aead74da (diff) | |
download | perfetto-2b4e9309d3a6a59d918416e5554449144acc10d5.tar.gz |
Merge "ui: Abstract Engine/EngineProxy behind interface" into main
Diffstat (limited to 'ui')
67 files changed, 246 insertions, 248 deletions
diff --git a/ui/src/common/plugins.ts b/ui/src/common/plugins.ts index 0f2b2b715..3a5899ed7 100644 --- a/ui/src/common/plugins.ts +++ b/ui/src/common/plugins.ts @@ -21,7 +21,6 @@ import {globals} from '../frontend/globals'; import { Command, DetailsPanel, - EngineProxy, MetricVisualisation, Migrate, Plugin, @@ -36,7 +35,7 @@ import { GroupPredicate, TrackRef, } from '../public'; -import {Engine} from '../trace_processor/engine'; +import {EngineBase, Engine} from '../trace_processor/engine'; import {Actions} from './actions'; import {SCROLLING_TRACK_GROUP} from './state'; @@ -103,9 +102,12 @@ export class PluginContextImpl implements PluginContext, Disposable { class PluginContextTraceImpl implements PluginContextTrace, Disposable { private trash = new Trash(); private alive = true; + readonly engine: Engine; - constructor(private ctx: PluginContext, readonly engine: EngineProxy) { - this.trash.add(engine); + constructor(private ctx: PluginContext, engine: EngineBase) { + const engineProxy = engine.getProxy(ctx.pluginId); + this.trash.add(engineProxy); + this.engine = engineProxy; } registerCommand(cmd: Command): void { @@ -380,7 +382,7 @@ function makePlugin(info: PluginDescriptor): Plugin { export class PluginManager { private registry: PluginRegistry; private _plugins: Map<string, PluginDetails>; - private engine?: Engine; + private engine?: EngineBase; private flags = new Map<string, Flag>(); constructor(registry: PluginRegistry) { @@ -466,7 +468,7 @@ export class PluginManager { // If a trace is already loaded when plugin is activated, make sure to // call onTraceLoad(). if (this.engine) { - await doPluginTraceLoad(pluginDetails, this.engine, id); + await doPluginTraceLoad(pluginDetails, this.engine); } this._plugins.set(id, pluginDetails); @@ -528,7 +530,7 @@ export class PluginManager { } async onTraceLoad( - engine: Engine, + engine: EngineBase, beforeEach?: (id: string) => void, ): Promise<void> { this.engine = engine; @@ -546,7 +548,7 @@ export class PluginManager { // time. for (const {id, plugin} of pluginsShuffled) { beforeEach?.(id); - await doPluginTraceLoad(plugin, engine, id); + await doPluginTraceLoad(plugin, engine); } } @@ -571,14 +573,11 @@ export class PluginManager { async function doPluginTraceLoad( pluginDetails: PluginDetails, - engine: Engine, - pluginId: string, + engine: EngineBase, ): Promise<void> { const {plugin, context} = pluginDetails; - const engineProxy = engine.getProxy(pluginId); - - const traceCtx = new PluginContextTraceImpl(context, engineProxy); + const traceCtx = new PluginContextTraceImpl(context, engine); pluginDetails.traceContext = traceCtx; const startTime = performance.now(); diff --git a/ui/src/common/plugins_unittest.ts b/ui/src/common/plugins_unittest.ts index 55fc82d00..7efccdacf 100644 --- a/ui/src/common/plugins_unittest.ts +++ b/ui/src/common/plugins_unittest.ts @@ -14,12 +14,12 @@ import {globals} from '../frontend/globals'; import {Plugin} from '../public'; -import {Engine} from '../trace_processor/engine'; +import {EngineBase} from '../trace_processor/engine'; import {createEmptyState} from './empty_state'; import {PluginManager, PluginRegistry} from './plugins'; -class FakeEngine extends Engine { +class FakeEngine extends EngineBase { id: string = 'TestEngine'; rpcSendRequestBytes(_data: Uint8Array) {} diff --git a/ui/src/common/queries.ts b/ui/src/common/queries.ts index 857d8e95c..a6c461b8d 100644 --- a/ui/src/common/queries.ts +++ b/ui/src/common/queries.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {Row} from '../trace_processor/query_result'; const MAX_DISPLAY_ROWS = 10000; @@ -36,7 +36,7 @@ export interface QueryRunParams { export async function runQuery( sqlQuery: string, - engine: EngineProxy, + engine: Engine, params?: QueryRunParams, ): Promise<QueryResponse> { const startMs = performance.now(); diff --git a/ui/src/common/schema.ts b/ui/src/common/schema.ts index 75a4b2f3f..c3f33e42a 100644 --- a/ui/src/common/schema.ts +++ b/ui/src/common/schema.ts @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {STR} from '../trace_processor/query_result'; -const CACHED_SCHEMAS = new WeakMap<EngineProxy, DatabaseSchema>(); +const CACHED_SCHEMAS = new WeakMap<Engine, DatabaseSchema>(); export class SchemaError extends Error { constructor(message: string) { @@ -40,7 +40,7 @@ interface ColumnInfo { } async function getColumns( - engine: EngineProxy, + engine: Engine, table: string, ): Promise<ColumnInfo[]> { const result = await engine.query(`PRAGMA table_info(${table});`); @@ -83,7 +83,7 @@ export class DatabaseSchema { // Deliberately not exported. Users should call getSchema below and // participate in cacheing. -async function createSchema(engine: EngineProxy): Promise<DatabaseSchema> { +async function createSchema(engine: Engine): Promise<DatabaseSchema> { const tables: TableInfo[] = []; const result = await engine.query(`SELECT name from perfetto_tables;`); const it = result.iter({ @@ -108,7 +108,7 @@ async function createSchema(engine: EngineProxy): Promise<DatabaseSchema> { // The schemas are per-engine (i.e. they can't be statically determined // at build time) since we might be in httpd mode and not-running // against the version of trace_processor we build with. -export async function getSchema(engine: EngineProxy): Promise<DatabaseSchema> { +export async function getSchema(engine: Engine): Promise<DatabaseSchema> { const schema = CACHED_SCHEMAS.get(engine); if (schema === undefined) { const newSchema = await createSchema(engine); diff --git a/ui/src/common/track_helper.ts b/ui/src/common/track_helper.ts index 84808dfcb..396b9552b 100644 --- a/ui/src/common/track_helper.ts +++ b/ui/src/common/track_helper.ts @@ -19,16 +19,6 @@ export {Store} from '../base/store'; import {raf} from '../core/raf_scheduler'; import {globals} from '../frontend/globals'; -export {EngineProxy} from '../trace_processor/engine'; -export { - LONG, - LONG_NULL, - NUM, - NUM_NULL, - STR, - STR_NULL, -} from '../trace_processor/query_result'; - type FetchTimeline<Data> = ( start: time, end: time, diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts index c1f0d6e74..a2fd5924d 100644 --- a/ui/src/controller/trace_controller.ts +++ b/ui/src/controller/trace_controller.ts @@ -44,7 +44,7 @@ import { } from '../frontend/publish'; import {addQueryResultsTab} from '../frontend/query_result_tab'; import {Router} from '../frontend/router'; -import {Engine} from '../trace_processor/engine'; +import {Engine, EngineBase} from '../trace_processor/engine'; import {HttpRpcEngine} from '../trace_processor/http_rpc_engine'; import { LONG, @@ -224,7 +224,7 @@ async function defineMaxLayoutDepthSqlFunction(engine: Engine): Promise<void> { // trace opened in the UI (for now only one trace is supported). export class TraceController extends Controller<States> { private readonly engineId: string; - private engine?: Engine; + private engine?: EngineBase; constructor(engineId: string) { super('init'); @@ -766,7 +766,7 @@ export class TraceController extends Controller<States> { private async listTracks() { this.updateStatus('Loading tracks'); - const engine = assertExists<Engine>(this.engine); + const engine = assertExists(this.engine); const actions = await decideTracks(engine); globals.dispatchMultiple(actions); } @@ -918,7 +918,7 @@ export class TraceController extends Controller<States> { } async initialiseHelperViews() { - const engine = assertExists<Engine>(this.engine); + const engine = assertExists(this.engine); this.updateStatus('Creating annotation counter track table'); // Create the helper tables for all the annotations related data. diff --git a/ui/src/controller/track_decider.ts b/ui/src/controller/track_decider.ts index f0c7ef483..e1b907c90 100644 --- a/ui/src/controller/track_decider.ts +++ b/ui/src/controller/track_decider.ts @@ -27,7 +27,7 @@ import {globals} from '../frontend/globals'; import {PERF_SAMPLE_FLAG} from '../core/feature_flags'; import {PrimaryTrackSortKey} from '../public'; import {getTrackName} from '../public/utils'; -import {Engine, EngineProxy} from '../trace_processor/engine'; +import {Engine, EngineBase} from '../trace_processor/engine'; import {NUM, NUM_NULL, STR, STR_NULL} from '../trace_processor/query_result'; import {ASYNC_SLICE_TRACK_KIND} from '../core_plugins/async_slices'; import { @@ -76,18 +76,20 @@ const CHROME_TRACK_REGEX = new RegExp('^Chrome.*|^InputLatency::.*'); const CHROME_TRACK_GROUP = 'Chrome Global Tracks'; const MISC_GROUP = 'Misc Global Tracks'; -export async function decideTracks(engine: Engine): Promise<DeferredAction[]> { +export async function decideTracks( + engine: EngineBase, +): Promise<DeferredAction[]> { return new TrackDecider(engine).decideTracks(); } class TrackDecider { - private engine: Engine; + private engine: EngineBase; private upidToUuid = new Map<number, string>(); private utidToUuid = new Map<number, string>(); private tracksToAdd: AddTrackArgs[] = []; private addTrackGroupActions: DeferredAction[] = []; - constructor(engine: Engine) { + constructor(engine: EngineBase) { this.engine = engine; } @@ -131,7 +133,7 @@ class TrackDecider { } } - async addCpuFreqTracks(engine: EngineProxy): Promise<void> { + async addCpuFreqTracks(engine: Engine): Promise<void> { const cpus = await this.engine.getCpus(); for (const cpu of cpus) { @@ -165,7 +167,7 @@ class TrackDecider { } } - async addGlobalAsyncTracks(engine: EngineProxy): Promise<void> { + async addGlobalAsyncTracks(engine: Engine): Promise<void> { const rawGlobalAsyncTracks = await engine.query(` with global_tracks_grouped as ( select distinct t.parent_id, t.name @@ -226,7 +228,7 @@ class TrackDecider { } } - async addGpuFreqTracks(engine: EngineProxy): Promise<void> { + async addGpuFreqTracks(engine: Engine): Promise<void> { const numGpus = await this.engine.getNumberOfGpus(); for (let gpu = 0; gpu < numGpus; gpu++) { // Only add a gpu freq track if we have @@ -248,7 +250,7 @@ class TrackDecider { } } - async addCpuFreqLimitCounterTracks(engine: EngineProxy): Promise<void> { + async addCpuFreqLimitCounterTracks(engine: Engine): Promise<void> { const cpuFreqLimitCounterTracksSql = ` select name, id from cpu_counter_track @@ -259,7 +261,7 @@ class TrackDecider { this.addCpuCounterTracks(engine, cpuFreqLimitCounterTracksSql); } - async addCpuPerfCounterTracks(engine: EngineProxy): Promise<void> { + async addCpuPerfCounterTracks(engine: Engine): Promise<void> { // Perf counter tracks are bound to CPUs, follow the scheduling and // frequency track naming convention ("Cpu N ..."). // Note: we might not have a track for a given cpu if no data was seen from @@ -274,7 +276,7 @@ class TrackDecider { this.addCpuCounterTracks(engine, addCpuPerfCounterTracksSql); } - async addCpuCounterTracks(engine: EngineProxy, sql: string): Promise<void> { + async addCpuCounterTracks(engine: Engine, sql: string): Promise<void> { const result = await engine.query(sql); const it = result.iter({ @@ -516,7 +518,7 @@ class TrackDecider { } } - async addAnnotationTracks(engine: EngineProxy): Promise<void> { + async addAnnotationTracks(engine: Engine): Promise<void> { const sliceResult = await engine.query(` select id, name, upid, group_name from annotation_slice_track @@ -607,7 +609,7 @@ class TrackDecider { } } - async addThreadStateTracks(engine: EngineProxy): Promise<void> { + async addThreadStateTracks(engine: Engine): Promise<void> { const result = await engine.query(` select utid, @@ -657,7 +659,7 @@ class TrackDecider { } } - async addThreadCpuSampleTracks(engine: EngineProxy): Promise<void> { + async addThreadCpuSampleTracks(engine: Engine): Promise<void> { const result = await engine.query(` with thread_cpu_sample as ( select distinct utid @@ -695,7 +697,7 @@ class TrackDecider { } } - async addThreadCounterTracks(engine: EngineProxy): Promise<void> { + async addThreadCounterTracks(engine: Engine): Promise<void> { const result = await engine.query(` select thread_counter_track.name as trackName, @@ -745,7 +747,7 @@ class TrackDecider { } } - async addProcessAsyncSliceTracks(engine: EngineProxy): Promise<void> { + async addProcessAsyncSliceTracks(engine: Engine): Promise<void> { const result = await engine.query(` select upid, @@ -790,7 +792,7 @@ class TrackDecider { } } - async addUserAsyncSliceTracks(engine: EngineProxy): Promise<void> { + async addUserAsyncSliceTracks(engine: Engine): Promise<void> { const result = await engine.query(` with grouped_packages as materialized ( select @@ -848,7 +850,7 @@ class TrackDecider { } } - async addActualFramesTracks(engine: EngineProxy): Promise<void> { + async addActualFramesTracks(engine: Engine): Promise<void> { const result = await engine.query(` select upid, @@ -891,7 +893,7 @@ class TrackDecider { } } - async addExpectedFramesTracks(engine: EngineProxy): Promise<void> { + async addExpectedFramesTracks(engine: Engine): Promise<void> { const result = await engine.query(` select upid, @@ -935,7 +937,7 @@ class TrackDecider { } } - async addThreadSliceTracks(engine: EngineProxy): Promise<void> { + async addThreadSliceTracks(engine: Engine): Promise<void> { const result = await engine.query(` select thread_track.utid as utid, @@ -990,7 +992,7 @@ class TrackDecider { } } - async addProcessCounterTracks(engine: EngineProxy): Promise<void> { + async addProcessCounterTracks(engine: Engine): Promise<void> { const result = await engine.query(` select process_counter_track.id as trackId, @@ -1034,7 +1036,7 @@ class TrackDecider { } } - async addProcessHeapProfileTracks(engine: EngineProxy): Promise<void> { + async addProcessHeapProfileTracks(engine: Engine): Promise<void> { const result = await engine.query(` select upid from _process_available_info_summary @@ -1052,7 +1054,7 @@ class TrackDecider { } } - async addProcessPerfSamplesTracks(engine: EngineProxy): Promise<void> { + async addProcessPerfSamplesTracks(engine: Engine): Promise<void> { const result = await engine.query(` select upid, pid from _process_available_info_summary @@ -1099,7 +1101,7 @@ class TrackDecider { this.upidToUuid.set(upid, uuid); } - async addKernelThreadGrouping(engine: EngineProxy): Promise<void> { + async addKernelThreadGrouping(engine: Engine): Promise<void> { // Identify kernel threads if this is a linux system trace, and sufficient // process information is available. Kernel threads are identified by being // children of kthreadd (always pid 2). @@ -1162,7 +1164,7 @@ class TrackDecider { } } - async addProcessTrackGroups(engine: EngineProxy): Promise<void> { + async addProcessTrackGroups(engine: Engine): Promise<void> { // We want to create groups of tracks in a specific order. // The tracks should be grouped: // by upid diff --git a/ui/src/core_plugins/android_log/logs_panel.ts b/ui/src/core_plugins/android_log/logs_panel.ts index e326a38e7..ecb1a3b49 100644 --- a/ui/src/core_plugins/android_log/logs_panel.ts +++ b/ui/src/core_plugins/android_log/logs_panel.ts @@ -21,7 +21,7 @@ import {DetailsShell} from '../../widgets/details_shell'; import {globals} from '../../frontend/globals'; import {Timestamp} from '../../frontend/widgets/timestamp'; -import {EngineProxy, LONG, NUM, NUM_NULL, Store, STR} from '../../public'; +import {Engine, LONG, NUM, NUM_NULL, Store, STR} from '../../public'; import {Monitor} from '../../base/monitor'; import {AsyncLimiter} from '../../base/async_limiter'; import {escapeGlob, escapeQuery} from '../../trace_processor/query_utils'; @@ -43,7 +43,7 @@ export interface LogFilteringCriteria { export interface LogPanelAttrs { filterStore: Store<LogFilteringCriteria>; - engine: EngineProxy; + engine: Engine; } interface Pagination { @@ -384,7 +384,7 @@ export class LogsFilters implements m.ClassComponent<LogsFiltersAttrs> { } async function updateLogEntries( - engine: EngineProxy, + engine: Engine, span: Span<time, duration>, pagination: Pagination, ): Promise<LogEntries> { @@ -450,10 +450,7 @@ async function updateLogEntries( }; } -async function updateLogView( - engine: EngineProxy, - filter: LogFilteringCriteria, -) { +async function updateLogView(engine: Engine, filter: LogFilteringCriteria) { await engine.query('drop view if exists filtered_logs'); const globMatch = composeGlobMatch(filter.hideNonMatching, filter.textEntry); diff --git a/ui/src/core_plugins/android_log/logs_track.ts b/ui/src/core_plugins/android_log/logs_track.ts index 1c5b3c609..7027a659c 100644 --- a/ui/src/core_plugins/android_log/logs_track.ts +++ b/ui/src/core_plugins/android_log/logs_track.ts @@ -14,11 +14,11 @@ import {Time, duration, time} from '../../base/time'; import {LIMIT, TrackData} from '../../common/track_data'; -import {LONG, NUM, TimelineFetcher} from '../../common/track_helper'; +import {TimelineFetcher} from '../../common/track_helper'; import {checkerboardExcept} from '../../frontend/checkerboard'; import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; -import {EngineProxy, Track} from '../../public'; +import {Engine, LONG, NUM, Track} from '../../public'; export interface Data extends TrackData { // Total number of log events within [start, end], before any quantization. @@ -52,7 +52,7 @@ interface LevelCfg { export class AndroidLogTrack implements Track { private fetcher = new TimelineFetcher<Data>(this.onBoundsChange.bind(this)); - constructor(private engine: EngineProxy) {} + constructor(private engine: Engine) {} async onUpdate(): Promise<void> { await this.fetcher.requestDataForCurrentTime(); diff --git a/ui/src/core_plugins/chrome_scroll_jank/index.ts b/ui/src/core_plugins/chrome_scroll_jank/index.ts index 1feb5cc47..4267f4c1d 100644 --- a/ui/src/core_plugins/chrome_scroll_jank/index.ts +++ b/ui/src/core_plugins/chrome_scroll_jank/index.ts @@ -25,7 +25,7 @@ import { PluginContextTrace, PluginDescriptor, } from '../../public'; -import {Engine, EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {ChromeTasksScrollJankTrack} from './chrome_tasks_scroll_jank_track'; import {EventLatencySliceDetailsPanel} from './event_latency_details_panel'; @@ -329,7 +329,7 @@ class ChromeScrollJankPlugin implements Plugin { } } -async function isChromeTrace(engine: EngineProxy) { +async function isChromeTrace(engine: Engine) { const queryResult = await engine.query(` select utid, upid from thread diff --git a/ui/src/core_plugins/chrome_scroll_jank/scroll_delta_graph.ts b/ui/src/core_plugins/chrome_scroll_jank/scroll_delta_graph.ts index d47601907..a2f644bca 100644 --- a/ui/src/core_plugins/chrome_scroll_jank/scroll_delta_graph.ts +++ b/ui/src/core_plugins/chrome_scroll_jank/scroll_delta_graph.ts @@ -15,7 +15,7 @@ import m from 'mithril'; import {duration, Time, time} from '../../base/time'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {LONG, NUM} from '../../trace_processor/query_result'; import {VegaView} from '../../widgets/vega_view'; @@ -45,7 +45,7 @@ export interface JankIntervalPlotDetails { } export async function getUserScrollDeltas( - engine: EngineProxy, + engine: Engine, startTs: time, dur: duration, ): Promise<ScrollDeltaDetails[]> { @@ -82,7 +82,7 @@ export async function getUserScrollDeltas( } export async function getAppliedScrollDeltas( - engine: EngineProxy, + engine: Engine, startTs: time, dur: duration, ): Promise<ScrollDeltaDetails[]> { @@ -123,7 +123,7 @@ export async function getAppliedScrollDeltas( } export async function getJankIntervals( - engine: EngineProxy, + engine: Engine, startTs: time, dur: duration, ): Promise<JankIntervalPlotDetails[]> { diff --git a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_cause_link_utils.ts b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_cause_link_utils.ts index 64e87849e..80ee9e25f 100644 --- a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_cause_link_utils.ts +++ b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_cause_link_utils.ts @@ -24,7 +24,7 @@ import { verticalScrollToTrack, } from '../../frontend/scroll_helper'; import {SliceSqlId} from '../../frontend/sql_types'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {LONG, NUM, STR} from '../../trace_processor/query_result'; import {Anchor} from '../../widgets/anchor'; @@ -53,7 +53,7 @@ export interface EventLatencyCauseThreadTracks { } export async function getScrollJankCauseStage( - engine: EngineProxy, + engine: Engine, eventLatencyId: SliceSqlId, ): Promise<EventLatencyStage | undefined> { const queryResult = await engine.query(` @@ -95,7 +95,7 @@ export async function getScrollJankCauseStage( } export async function getEventLatencyCauseTracks( - engine: EngineProxy, + engine: Engine, scrollJankCauseStage: EventLatencyStage, ): Promise<EventLatencyCauseThreadTracks[]> { const threadTracks: EventLatencyCauseThreadTracks[] = []; @@ -130,7 +130,7 @@ export async function getEventLatencyCauseTracks( } async function getChromeCauseTracks( - engine: EngineProxy, + engine: Engine, eventLatencySliceId: number, processName: CauseProcess, threadName: CauseThread, diff --git a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_slice.ts b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_slice.ts index c05ac4347..6dab538f3 100644 --- a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_slice.ts +++ b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_slice.ts @@ -24,7 +24,7 @@ import { constraintsToQuerySuffix, SQLConstraints, } from '../../frontend/sql_utils'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {LONG, NUM} from '../../trace_processor/query_result'; import {Anchor} from '../../widgets/anchor'; @@ -45,7 +45,7 @@ interface BasicSlice { } async function getSlicesFromTrack( - engine: EngineProxy, + engine: Engine, track: ScrollJankTrackSpec, constraints: SQLConstraints, ): Promise<BasicSlice[]> { @@ -75,7 +75,7 @@ async function getSlicesFromTrack( export type ScrollJankSlice = BasicSlice; export async function getScrollJankSlices( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<ScrollJankSlice[]> { const track = ScrollJankPluginState.getInstance().getTrack( @@ -93,7 +93,7 @@ export async function getScrollJankSlices( export type EventLatencySlice = BasicSlice; export async function getEventLatencySlice( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<EventLatencySlice | undefined> { const track = ScrollJankPluginState.getInstance().getTrack( @@ -112,7 +112,7 @@ export async function getEventLatencySlice( } export async function getEventLatencyDescendantSlice( - engine: EngineProxy, + engine: Engine, id: number, descendant: string | undefined, ): Promise<EventLatencySlice | undefined> { diff --git a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_v3_details_panel.ts b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_v3_details_panel.ts index b117b086e..646b7c651 100644 --- a/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_v3_details_panel.ts +++ b/ui/src/core_plugins/chrome_scroll_jank/scroll_jank_v3_details_panel.ts @@ -24,7 +24,7 @@ import {asSliceSqlId} from '../../frontend/sql_types'; import {sqlValueToString} from '../../frontend/sql_utils'; import {DurationWidget} from '../../frontend/widgets/duration'; import {Timestamp} from '../../frontend/widgets/timestamp'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {LONG, NUM, STR} from '../../trace_processor/query_result'; import {DetailsShell} from '../../widgets/details_shell'; import {GridLayout, GridLayoutColumn} from '../../widgets/grid_layout'; @@ -61,7 +61,7 @@ interface Data { } async function getSliceDetails( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<SliceDetails | undefined> { return getSlice(engine, asSliceSqlId(id)); diff --git a/ui/src/core_plugins/cpu_freq/index.ts b/ui/src/core_plugins/cpu_freq/index.ts index b5fa5fa4b..07b9b1d88 100644 --- a/ui/src/core_plugins/cpu_freq/index.ts +++ b/ui/src/core_plugins/cpu_freq/index.ts @@ -24,7 +24,7 @@ import {checkerboardExcept} from '../../frontend/checkerboard'; import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; import { - EngineProxy, + Engine, Plugin, PluginContextTrace, PluginDescriptor, @@ -62,11 +62,11 @@ class CpuFreqTrack implements Track { private hoveredIdle: number | undefined = undefined; private fetcher = new TimelineFetcher<Data>(this.onBoundsChange.bind(this)); - private engine: EngineProxy; + private engine: Engine; private config: Config; private trackUuid = uuidv4Sql(); - constructor(config: Config, engine: EngineProxy) { + constructor(config: Config, engine: Engine) { this.config = config; this.engine = engine; } diff --git a/ui/src/core_plugins/cpu_profile/index.ts b/ui/src/core_plugins/cpu_profile/index.ts index 4d3e87fd9..364225d88 100644 --- a/ui/src/core_plugins/cpu_profile/index.ts +++ b/ui/src/core_plugins/cpu_profile/index.ts @@ -24,7 +24,7 @@ import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; import {TimeScale} from '../../frontend/time_scale'; import { - EngineProxy, + Engine, Plugin, PluginContextTrace, PluginDescriptor, @@ -54,10 +54,10 @@ class CpuProfileTrack implements Track { private markerWidth = (this.getHeight() - MARGIN_TOP - BAR_HEIGHT) / 2; private hoveredTs: time | undefined = undefined; private fetcher = new TimelineFetcher<Data>(this.onBoundsChange.bind(this)); - private engine: EngineProxy; + private engine: Engine; private utid: number; - constructor(engine: EngineProxy, utid: number) { + constructor(engine: Engine, utid: number) { this.engine = engine; this.utid = utid; } diff --git a/ui/src/core_plugins/cpu_slices/index.ts b/ui/src/core_plugins/cpu_slices/index.ts index 139bac5c3..1fc1e67e6 100644 --- a/ui/src/core_plugins/cpu_slices/index.ts +++ b/ui/src/core_plugins/cpu_slices/index.ts @@ -33,7 +33,7 @@ import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; import {SliceDetailsPanel} from '../../frontend/slice_details_panel'; import { - EngineProxy, + Engine, Plugin, PluginContextTrace, PluginDescriptor, @@ -67,12 +67,12 @@ class CpuSliceTrack implements Track { private fetcher = new TimelineFetcher<Data>(this.onBoundsChange.bind(this)); private lastRowId = -1; - private engine: EngineProxy; + private engine: Engine; private cpu: number; private trackKey: string; private trackUuid = uuidv4Sql(); - constructor(engine: EngineProxy, trackKey: string, cpu: number) { + constructor(engine: Engine, trackKey: string, cpu: number) { this.engine = engine; this.trackKey = trackKey; this.cpu = cpu; @@ -490,7 +490,7 @@ class CpuSlices implements Plugin { }); } - async guessCpuSizes(engine: EngineProxy): Promise<Map<number, string>> { + async guessCpuSizes(engine: Engine): Promise<Map<number, string>> { const cpuToSize = new Map<number, string>(); await engine.query(` INCLUDE PERFETTO MODULE cpu.size; diff --git a/ui/src/core_plugins/debug/add_debug_track_menu.ts b/ui/src/core_plugins/debug/add_debug_track_menu.ts index e03c9f225..a0c5b31ae 100644 --- a/ui/src/core_plugins/debug/add_debug_track_menu.ts +++ b/ui/src/core_plugins/debug/add_debug_track_menu.ts @@ -16,7 +16,7 @@ import m from 'mithril'; import {findRef} from '../../base/dom_utils'; import {raf} from '../../core/raf_scheduler'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {Form, FormLabel} from '../../widgets/form'; import {Select} from '../../widgets/select'; import {TextInput} from '../../widgets/text_input'; @@ -36,7 +36,7 @@ export function uuidToViewName(uuid: string): string { interface AddDebugTrackMenuAttrs { dataSource: Required<SqlDataSource>; - engine: EngineProxy; + engine: Engine; } const TRACK_NAME_FIELD_REF = 'TRACK_NAME_FIELD'; diff --git a/ui/src/core_plugins/debug/counter_track.ts b/ui/src/core_plugins/debug/counter_track.ts index 5b37e3d1b..56274d3fc 100644 --- a/ui/src/core_plugins/debug/counter_track.ts +++ b/ui/src/core_plugins/debug/counter_track.ts @@ -16,7 +16,7 @@ import m from 'mithril'; import {BaseCounterTrack} from '../../frontend/base_counter_track'; import {TrackContext} from '../../public'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {CounterDebugTrackConfig} from '../../frontend/debug_tracks'; import {Disposable, DisposableCallback} from '../../base/disposable'; import {uuidv4Sql} from '../../base/uuid'; @@ -25,7 +25,7 @@ export class DebugCounterTrack extends BaseCounterTrack { private config: CounterDebugTrackConfig; private sqlTableName: string; - constructor(engine: EngineProxy, ctx: TrackContext) { + constructor(engine: Engine, ctx: TrackContext) { super({ engine, trackKey: ctx.trackKey, diff --git a/ui/src/core_plugins/debug/slice_track.ts b/ui/src/core_plugins/debug/slice_track.ts index a53e4dcf1..49e51423e 100644 --- a/ui/src/core_plugins/debug/slice_track.ts +++ b/ui/src/core_plugins/debug/slice_track.ts @@ -14,7 +14,7 @@ import {NamedSliceTrackTypes} from '../../frontend/named_slice_track'; import {TrackContext} from '../../public'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import { CustomSqlDetailsPanelConfig, CustomSqlTableDefConfig, @@ -40,7 +40,7 @@ export class DebugTrackV2 extends CustomSqlTableSliceTrack<NamedSliceTrackTypes> private config: DebugTrackV2Config; private sqlTableName: string; - constructor(engine: EngineProxy, ctx: TrackContext) { + constructor(engine: Engine, ctx: TrackContext) { super({ engine, trackKey: ctx.trackKey, diff --git a/ui/src/core_plugins/frames/actual_frames_track_v2.ts b/ui/src/core_plugins/frames/actual_frames_track_v2.ts index 6ce0e3d51..10b7d72b9 100644 --- a/ui/src/core_plugins/frames/actual_frames_track_v2.ts +++ b/ui/src/core_plugins/frames/actual_frames_track_v2.ts @@ -20,7 +20,7 @@ import { NamedSliceTrackTypes, } from '../../frontend/named_slice_track'; import {SLICE_LAYOUT_FIT_CONTENT_DEFAULTS} from '../../frontend/slice_layout'; -import {EngineProxy, Slice, STR_NULL} from '../../public'; +import {Engine, Slice, STR_NULL} from '../../public'; // color named and defined based on Material Design color palettes // 500 colors indicate a timeline slice is not a partial jank (not a jank or @@ -54,7 +54,7 @@ export interface ActualFrameTrackTypes extends NamedSliceTrackTypes { export class ActualFramesTrack extends NamedSliceTrack<ActualFrameTrackTypes> { constructor( - engine: EngineProxy, + engine: Engine, maxDepth: number, trackKey: string, private trackIds: number[], diff --git a/ui/src/core_plugins/frames/expected_frames_track_v2.ts b/ui/src/core_plugins/frames/expected_frames_track_v2.ts index ce602a1dd..e9cce1297 100644 --- a/ui/src/core_plugins/frames/expected_frames_track_v2.ts +++ b/ui/src/core_plugins/frames/expected_frames_track_v2.ts @@ -16,13 +16,13 @@ import {HSLColor} from '../../core/color'; import {makeColorScheme} from '../../core/colorizer'; import {NamedRow, NamedSliceTrack} from '../../frontend/named_slice_track'; import {SLICE_LAYOUT_FIT_CONTENT_DEFAULTS} from '../../frontend/slice_layout'; -import {EngineProxy, Slice} from '../../public'; +import {Engine, Slice} from '../../public'; const GREEN = makeColorScheme(new HSLColor('#4CAF50')); // Green 500 export class ExpectedFramesTrack extends NamedSliceTrack { constructor( - engine: EngineProxy, + engine: Engine, maxDepth: number, trackKey: string, private trackIds: number[], diff --git a/ui/src/core_plugins/ftrace/ftrace_explorer.ts b/ui/src/core_plugins/ftrace/ftrace_explorer.ts index d8cad7838..e03418327 100644 --- a/ui/src/core_plugins/ftrace/ftrace_explorer.ts +++ b/ui/src/core_plugins/ftrace/ftrace_explorer.ts @@ -28,7 +28,7 @@ import {PopupPosition} from '../../widgets/popup'; import {globals} from '../../frontend/globals'; import {Timestamp} from '../../frontend/widgets/timestamp'; import {FtraceFilter, FtraceStat} from './common'; -import {EngineProxy, LONG, NUM, Store, STR, STR_NULL} from '../../public'; +import {Engine, LONG, NUM, Store, STR, STR_NULL} from '../../public'; import {raf} from '../../core/raf_scheduler'; import {AsyncLimiter} from '../../base/async_limiter'; import {Monitor} from '../../base/monitor'; @@ -40,7 +40,7 @@ const ROW_H = 20; interface FtraceExplorerAttrs { cache: FtraceExplorerCache; filterStore: Store<FtraceFilter>; - engine: EngineProxy; + engine: Engine; } interface FtraceEvent { @@ -69,7 +69,7 @@ export interface FtraceExplorerCache { counters: FtraceStat[]; } -async function getFtraceCounters(engine: EngineProxy): Promise<FtraceStat[]> { +async function getFtraceCounters(engine: Engine): Promise<FtraceStat[]> { // TODO(stevegolton): this is an extraordinarily slow query on large traces // as it goes through every ftrace event which can be a lot on big traces. // Consider if we can have some different UX which avoids needing these @@ -264,7 +264,7 @@ export class FtraceExplorer implements m.ClassComponent<FtraceExplorerAttrs> { } async function lookupFtraceEvents( - engine: EngineProxy, + engine: Engine, offset: number, count: number, filter: FtraceFilter, diff --git a/ui/src/core_plugins/ftrace/ftrace_track.ts b/ui/src/core_plugins/ftrace/ftrace_track.ts index 6950eca4f..ed55cf6e5 100644 --- a/ui/src/core_plugins/ftrace/ftrace_track.ts +++ b/ui/src/core_plugins/ftrace/ftrace_track.ts @@ -20,7 +20,7 @@ import {checkerboardExcept} from '../../frontend/checkerboard'; import {globals} from '../../frontend/globals'; import {TrackData} from '../../common/track_data'; import {PanelSize} from '../../frontend/panel'; -import {EngineProxy, Track} from '../../public'; +import {Engine, Track} from '../../public'; import {LONG, STR} from '../../trace_processor/query_result'; import {FtraceFilter} from './common'; import {Store} from '../../public'; @@ -41,12 +41,12 @@ export interface Config { export class FtraceRawTrack implements Track { private fetcher = new TimelineFetcher(this.onBoundsChange.bind(this)); - private engine: EngineProxy; + private engine: Engine; private cpu: number; private store: Store<FtraceFilter>; private readonly monitor: Monitor; - constructor(engine: EngineProxy, cpu: number, store: Store<FtraceFilter>) { + constructor(engine: Engine, cpu: number, store: Store<FtraceFilter>) { this.engine = engine; this.cpu = cpu; this.store = store; diff --git a/ui/src/core_plugins/ftrace/index.ts b/ui/src/core_plugins/ftrace/index.ts index 3cc06162b..9539c788e 100644 --- a/ui/src/core_plugins/ftrace/index.ts +++ b/ui/src/core_plugins/ftrace/index.ts @@ -16,7 +16,7 @@ import m from 'mithril'; import {FtraceExplorer, FtraceExplorerCache} from './ftrace_explorer'; import { - EngineProxy, + Engine, Plugin, PluginContextTrace, PluginDescriptor, @@ -108,7 +108,7 @@ class FtraceRawPlugin implements Plugin { this.trash.dispose(); } - private async lookupCpuCores(engine: EngineProxy): Promise<number[]> { + private async lookupCpuCores(engine: Engine): Promise<number[]> { const query = 'select distinct cpu from ftrace_event'; const result = await engine.query(query); diff --git a/ui/src/core_plugins/perf_samples_profile/index.ts b/ui/src/core_plugins/perf_samples_profile/index.ts index 752684a89..319fb255c 100644 --- a/ui/src/core_plugins/perf_samples_profile/index.ts +++ b/ui/src/core_plugins/perf_samples_profile/index.ts @@ -24,7 +24,7 @@ import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; import {TimeScale} from '../../frontend/time_scale'; import { - EngineProxy, + Engine, Plugin, PluginContextTrace, PluginDescriptor, @@ -50,9 +50,9 @@ class PerfSamplesProfileTrack implements Track { private hoveredTs: time | undefined = undefined; private fetcher = new TimelineFetcher(this.onBoundsChange.bind(this)); private upid: number; - private engine: EngineProxy; + private engine: Engine; - constructor(engine: EngineProxy, upid: number) { + constructor(engine: Engine, upid: number) { this.upid = upid; this.engine = engine; } diff --git a/ui/src/core_plugins/process_summary/process_scheduling_track.ts b/ui/src/core_plugins/process_summary/process_scheduling_track.ts index 9725c2914..28b536f50 100644 --- a/ui/src/core_plugins/process_summary/process_scheduling_track.ts +++ b/ui/src/core_plugins/process_summary/process_scheduling_track.ts @@ -25,7 +25,7 @@ import {TimelineFetcher} from '../../common/track_helper'; import {checkerboardExcept} from '../../frontend/checkerboard'; import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; -import {EngineProxy, Track} from '../../public'; +import {Engine, Track} from '../../public'; import {LONG, NUM, QueryResult} from '../../trace_processor/query_result'; import {uuidv4Sql} from '../../base/uuid'; @@ -57,11 +57,11 @@ export class ProcessSchedulingTrack implements Track { private utidHoveredInThisTrack = -1; private fetcher = new TimelineFetcher(this.onBoundsChange.bind(this)); private maxCpu = 0; - private engine: EngineProxy; + private engine: Engine; private trackUuid = uuidv4Sql(); private config: Config; - constructor(engine: EngineProxy, config: Config) { + constructor(engine: Engine, config: Config) { this.engine = engine; this.config = config; } diff --git a/ui/src/core_plugins/process_summary/process_summary_track.ts b/ui/src/core_plugins/process_summary/process_summary_track.ts index 7acf36bf8..5fa31dec3 100644 --- a/ui/src/core_plugins/process_summary/process_summary_track.ts +++ b/ui/src/core_plugins/process_summary/process_summary_track.ts @@ -19,11 +19,11 @@ import {assertExists, assertFalse} from '../../base/logging'; import {duration, Time, time} from '../../base/time'; import {colorForTid} from '../../core/colorizer'; import {LIMIT, TrackData} from '../../common/track_data'; -import {EngineProxy, TimelineFetcher} from '../../common/track_helper'; +import {TimelineFetcher} from '../../common/track_helper'; import {checkerboardExcept} from '../../frontend/checkerboard'; import {globals} from '../../frontend/globals'; import {PanelSize} from '../../frontend/panel'; -import {Track} from '../../public'; +import {Engine, Track} from '../../public'; import {NUM} from '../../trace_processor/query_result'; export const PROCESS_SUMMARY_TRACK = 'ProcessSummaryTrack'; @@ -47,11 +47,11 @@ const SUMMARY_HEIGHT = TRACK_HEIGHT - MARGIN_TOP; export class ProcessSummaryTrack implements Track { private fetcher = new TimelineFetcher<Data>(this.onBoundsChange.bind(this)); - private engine: EngineProxy; + private engine: Engine; private uuid = uuidv4(); private config: Config; - constructor(engine: EngineProxy, config: Config) { + constructor(engine: Engine, config: Config) { this.engine = engine; this.config = config; } diff --git a/ui/src/core_plugins/sched/active_cpu_count.ts b/ui/src/core_plugins/sched/active_cpu_count.ts index 721a8841c..2ab49bcf2 100644 --- a/ui/src/core_plugins/sched/active_cpu_count.ts +++ b/ui/src/core_plugins/sched/active_cpu_count.ts @@ -25,7 +25,7 @@ import { } from '../../frontend/base_counter_track'; import {CloseTrackButton} from '../../frontend/close_track_button'; import {globals} from '../../frontend/globals'; -import {EngineProxy, PrimaryTrackSortKey, TrackContext} from '../../public'; +import {Engine, PrimaryTrackSortKey, TrackContext} from '../../public'; export function addActiveCPUCountTrack(cpuType?: string) { const cpuTypeName = cpuType === undefined ? '' : ` ${cpuType} `; @@ -56,7 +56,7 @@ export class ActiveCPUCountTrack extends BaseCounterTrack { static readonly kind = 'dev.perfetto.Sched.ActiveCPUCount'; - constructor(ctx: TrackContext, engine: EngineProxy) { + constructor(ctx: TrackContext, engine: Engine) { super({ engine, trackKey: ctx.trackKey, diff --git a/ui/src/core_plugins/screenshots/screenshot_panel.ts b/ui/src/core_plugins/screenshots/screenshot_panel.ts index 066d14c18..387ebf689 100644 --- a/ui/src/core_plugins/screenshots/screenshot_panel.ts +++ b/ui/src/core_plugins/screenshots/screenshot_panel.ts @@ -20,10 +20,10 @@ import {BottomTab, NewBottomTabArgs} from '../../frontend/bottom_tab'; import {GenericSliceDetailsTabConfig} from '../../frontend/generic_slice_details_tab'; import {getSlice, SliceDetails} from '../../frontend/sql/slice'; import {asSliceSqlId} from '../../frontend/sql_types'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; async function getSliceDetails( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<SliceDetails | undefined> { return getSlice(engine, asSliceSqlId(id)); diff --git a/ui/src/frontend/app.ts b/ui/src/frontend/app.ts index 92301b715..18adc7f24 100644 --- a/ui/src/frontend/app.ts +++ b/ui/src/frontend/app.ts @@ -32,7 +32,7 @@ import { } from '../core/timestamp_format'; import {raf} from '../core/raf_scheduler'; import {Command} from '../public'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {THREAD_STATE_TRACK_KIND} from '../core_plugins/thread_state'; import {HotkeyConfig, HotkeyContext} from '../widgets/hotkey_context'; import {HotkeyGlyphs} from '../widgets/hotkey_glyphs'; @@ -155,7 +155,7 @@ export class App implements m.ClassComponent { this.trash.add(new AggregationsTabs()); } - private getEngine(): EngineProxy | undefined { + private getEngine(): Engine | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) { return undefined; diff --git a/ui/src/frontend/base_counter_track.ts b/ui/src/frontend/base_counter_track.ts index 990e6a36d..9a37a6a46 100644 --- a/ui/src/frontend/base_counter_track.ts +++ b/ui/src/frontend/base_counter_track.ts @@ -20,7 +20,7 @@ import {assertTrue, assertUnreachable} from '../base/logging'; import {Time, time} from '../base/time'; import {drawTrackHoverTooltip} from '../common/canvas_utils'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy, LONG, NUM, Track} from '../public'; +import {Engine, LONG, NUM, Track} from '../public'; import {Button} from '../widgets/button'; import {MenuItem, MenuDivider, PopupMenu2} from '../widgets/menu'; @@ -194,7 +194,7 @@ export type BaseCounterTrackArgs = NewTrackArgs & { }; export abstract class BaseCounterTrack implements Track { - protected engine: EngineProxy; + protected engine: Engine; protected trackKey: string; protected trackUuid = uuidv4Sql(); diff --git a/ui/src/frontend/base_slice_track.ts b/ui/src/frontend/base_slice_track.ts index 7e013ccc1..720ace25c 100644 --- a/ui/src/frontend/base_slice_track.ts +++ b/ui/src/frontend/base_slice_track.ts @@ -32,7 +32,7 @@ import { } from '../common/state'; import {featureFlags} from '../core/feature_flags'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy, Slice, SliceRect, Track} from '../public'; +import {Engine, Slice, SliceRect, Track} from '../public'; import {LONG, NUM} from '../trace_processor/query_result'; import {checkerboardExcept} from './checkerboard'; @@ -175,7 +175,7 @@ export abstract class BaseSliceTrack< > implements Track { protected sliceLayout: SliceLayout = {...DEFAULT_SLICE_LAYOUT}; - protected engine: EngineProxy; + protected engine: Engine; protected trackKey: string; protected trackUuid = uuidv4Sql(); diff --git a/ui/src/frontend/bottom_tab.ts b/ui/src/frontend/bottom_tab.ts index d8ed117db..9868a605f 100644 --- a/ui/src/frontend/bottom_tab.ts +++ b/ui/src/frontend/bottom_tab.ts @@ -14,10 +14,10 @@ import m from 'mithril'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; export interface NewBottomTabArgs<Config> { - engine: EngineProxy; + engine: Engine; tag?: string; uuid: string; config: Config; @@ -43,7 +43,7 @@ export abstract class BottomTabBase<Config = {}> { // Config for this details panel. Should be serializable. protected readonly config: Config; // Engine for running queries and fetching additional data. - protected readonly engine: EngineProxy; + protected readonly engine: Engine; // Optional tag, which is used to ensure that only one tab // with the same tag can exist - adding a new tab with the same tag // (e.g. 'current_selection') would close the previous one. This diff --git a/ui/src/frontend/chrome_slice_details_tab.ts b/ui/src/frontend/chrome_slice_details_tab.ts index 49196fa21..91cf54f54 100644 --- a/ui/src/frontend/chrome_slice_details_tab.ts +++ b/ui/src/frontend/chrome_slice_details_tab.ts @@ -19,7 +19,7 @@ import {duration, Time, TimeSpan} from '../base/time'; import {exists} from '../base/utils'; import {runQuery} from '../common/queries'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {LONG, LONG_NULL, NUM, STR_NULL} from '../trace_processor/query_result'; import {Button} from '../widgets/button'; import {DetailsShell} from '../widgets/details_shell'; @@ -167,7 +167,7 @@ function getSliceContextMenuItems(slice: SliceDetails) { return ITEMS.filter((item) => item.shouldDisplay(slice)); } -function getEngine(): EngineProxy | undefined { +function getEngine(): Engine | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) { return undefined; @@ -177,7 +177,7 @@ function getEngine(): EngineProxy | undefined { } async function getAnnotationSlice( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<SliceDetails | undefined> { const query = await engine.query(` @@ -218,7 +218,7 @@ async function getAnnotationSlice( } async function getSliceDetails( - engine: EngineProxy, + engine: Engine, id: number, table: string, ): Promise<SliceDetails | undefined> { @@ -300,7 +300,7 @@ export class ChromeSliceDetailsTab extends BottomTab<ChromeSliceDetailsTabConfig return !exists(this.sliceDetails); } - private renderRhs(engine: EngineProxy, slice: SliceDetails): m.Children { + private renderRhs(engine: Engine, slice: SliceDetails): m.Children { const precFlows = this.renderPrecedingFlows(slice); const followingFlows = this.renderFollowingFlows(slice); const args = diff --git a/ui/src/frontend/debug_tracks.ts b/ui/src/frontend/debug_tracks.ts index ed77bf0da..7b3fe117f 100644 --- a/ui/src/frontend/debug_tracks.ts +++ b/ui/src/frontend/debug_tracks.ts @@ -16,7 +16,7 @@ import {uuidv4} from '../base/uuid'; import {Actions, DeferredAction} from '../common/actions'; import {SCROLLING_TRACK_GROUP} from '../common/state'; import {globals} from './globals'; -import {EngineProxy, PrimaryTrackSortKey} from '../public'; +import {Engine, PrimaryTrackSortKey} from '../public'; import {DebugTrackV2Config} from '../core_plugins/debug/slice_track'; export const ARG_PREFIX = 'arg_'; @@ -55,7 +55,7 @@ export interface SqlDataSource { // once or want to tweak the actions once produced. Otherwise, use // addDebugSliceTrack(). export async function createDebugSliceTrackActions( - _engine: EngineProxy, + _engine: Engine, data: SqlDataSource, trackName: string, sliceColumns: SliceColumns, @@ -90,7 +90,7 @@ export async function createDebugSliceTrackActions( } export async function addPivotDebugSliceTracks( - engine: EngineProxy, + engine: Engine, data: SqlDataSource, trackName: string, sliceColumns: SliceColumns, @@ -129,7 +129,7 @@ export async function addPivotDebugSliceTracks( // Adds a debug track immediately. Use createDebugSliceTrackActions() if you // want to create many tracks at once. export async function addDebugSliceTrack( - engine: EngineProxy, + engine: Engine, data: SqlDataSource, trackName: string, sliceColumns: SliceColumns, diff --git a/ui/src/frontend/globals.ts b/ui/src/frontend/globals.ts index 50b2286cb..bdb46ace5 100644 --- a/ui/src/frontend/globals.ts +++ b/ui/src/frontend/globals.ts @@ -44,7 +44,7 @@ import {TimestampFormat, timestampFormat} from '../core/timestamp_format'; import {TrackManager} from '../common/track_cache'; import {setPerfHooks} from '../core/perf'; import {raf} from '../core/raf_scheduler'; -import {Engine} from '../trace_processor/engine'; +import {EngineBase} from '../trace_processor/engine'; import {HttpRpcState} from '../trace_processor/http_rpc_engine'; import {Analytics, initAnalytics} from './analytics'; @@ -290,7 +290,7 @@ class Globals { count: new Uint8Array(0), }; - engines = new Map<string, Engine>(); + engines = new Map<string, EngineBase>(); initialize(dispatch: Dispatch, router: Router) { this._dispatch = dispatch; diff --git a/ui/src/frontend/metrics_page.ts b/ui/src/frontend/metrics_page.ts index 6b7ffcee0..124cb8491 100644 --- a/ui/src/frontend/metrics_page.ts +++ b/ui/src/frontend/metrics_page.ts @@ -25,7 +25,7 @@ import { import {pluginManager, PluginManager} from '../common/plugins'; import {raf} from '../core/raf_scheduler'; import {MetricVisualisation} from '../public'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {STR} from '../trace_processor/query_result'; import {Select} from '../widgets/select'; import {Spinner} from '../widgets/spinner'; @@ -37,7 +37,7 @@ import {createPage} from './pages'; type Format = 'json' | 'prototext' | 'proto'; const FORMATS: Format[] = ['json', 'prototext', 'proto']; -function getEngine(): EngineProxy | undefined { +function getEngine(): Engine | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) { return undefined; @@ -46,7 +46,7 @@ function getEngine(): EngineProxy | undefined { return engine; } -async function getMetrics(engine: EngineProxy): Promise<string[]> { +async function getMetrics(engine: Engine): Promise<string[]> { const metrics: string[] = []; const metricsResult = await engine.query('select name from trace_metrics'); for (const it = metricsResult.iter({name: STR}); it.valid(); it.next()) { @@ -56,7 +56,7 @@ async function getMetrics(engine: EngineProxy): Promise<string[]> { } async function getMetric( - engine: EngineProxy, + engine: Engine, metric: string, format: Format, ): Promise<string> { @@ -69,7 +69,7 @@ async function getMetric( } class MetricsController { - engine: EngineProxy; + engine: Engine; plugins: PluginManager; private _metrics: string[]; private _selected?: string; @@ -78,7 +78,7 @@ class MetricsController { // eslint-disable-next-line @typescript-eslint/no-explicit-any private _json: any; - constructor(plugins: PluginManager, engine: EngineProxy) { + constructor(plugins: PluginManager, engine: Engine) { this.plugins = plugins; this.engine = engine; this._metrics = []; diff --git a/ui/src/frontend/query_page.ts b/ui/src/frontend/query_page.ts index 7afcbaf20..80b8858e2 100644 --- a/ui/src/frontend/query_page.ts +++ b/ui/src/frontend/query_page.ts @@ -19,7 +19,7 @@ import {SimpleResizeObserver} from '../base/resize_observer'; import {undoCommonChatAppReplacements} from '../base/string_utils'; import {QueryResponse, runQuery} from '../common/queries'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {Callout} from '../widgets/callout'; import {Editor} from '../widgets/editor'; @@ -71,7 +71,7 @@ function runManualQuery(query: string) { raf.scheduleDelayedFullRedraw(); } -function getEngine(): EngineProxy | undefined { +function getEngine(): Engine | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) { return undefined; diff --git a/ui/src/frontend/query_result_tab.ts b/ui/src/frontend/query_result_tab.ts index 7fe7b2d10..e6feda324 100644 --- a/ui/src/frontend/query_result_tab.ts +++ b/ui/src/frontend/query_result_tab.ts @@ -32,7 +32,7 @@ import {QueryTable} from './query_table'; import {globals} from './globals'; import {Actions} from '../common/actions'; import {BottomTabToTabAdapter} from '../public/utils'; -import {EngineProxy} from '../public'; +import {Engine} from '../public'; interface QueryResultTabConfig { readonly query: string; @@ -66,7 +66,7 @@ export function addQueryResultsTab( } // TODO(stevegolton): Find a way to make this more elegant. -function getEngine(): EngineProxy { +function getEngine(): Engine { const engConfig = globals.getCurrentEngine(); const engineId = assertExists(engConfig).id; return assertExists(globals.engines.get(engineId)).getProxy('QueryResult'); diff --git a/ui/src/frontend/sidebar.ts b/ui/src/frontend/sidebar.ts index be1d20e97..1cedf6ac5 100644 --- a/ui/src/frontend/sidebar.ts +++ b/ui/src/frontend/sidebar.ts @@ -29,7 +29,7 @@ import {EngineMode} from '../common/state'; import {featureFlags} from '../core/feature_flags'; import {raf} from '../core/raf_scheduler'; import {SCM_REVISION, VERSION} from '../gen/perfetto_version'; -import {Engine} from '../trace_processor/engine'; +import {EngineBase} from '../trace_processor/engine'; import {showModal} from '../widgets/modal'; import {Animation} from './animation'; @@ -566,7 +566,7 @@ function downloadTrace(e: Event) { downloadUrl(fileName, url); } -function getCurrentEngine(): Engine | undefined { +function getCurrentEngine(): EngineBase | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) return undefined; return globals.engines.get(engineId); diff --git a/ui/src/frontend/simple_counter_track.ts b/ui/src/frontend/simple_counter_track.ts index 361480b2d..5b21ded1f 100644 --- a/ui/src/frontend/simple_counter_track.ts +++ b/ui/src/frontend/simple_counter_track.ts @@ -13,7 +13,7 @@ // limitations under the License. import m from 'mithril'; -import {EngineProxy, TrackContext} from '../public'; +import {Engine, TrackContext} from '../public'; import {BaseCounterTrack, CounterOptions} from './base_counter_track'; import {CounterColumns, SqlDataSource} from './debug_tracks'; import {Disposable, DisposableCallback} from '../base/disposable'; @@ -30,7 +30,7 @@ export class SimpleCounterTrack extends BaseCounterTrack { private sqlTableName: string; constructor( - engine: EngineProxy, + engine: Engine, ctx: TrackContext, config: SimpleCounterTrackConfig, ) { diff --git a/ui/src/frontend/simple_slice_track.ts b/ui/src/frontend/simple_slice_track.ts index f46812fad..c292fe6b3 100644 --- a/ui/src/frontend/simple_slice_track.ts +++ b/ui/src/frontend/simple_slice_track.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {EngineProxy, TrackContext} from '../public'; +import {Engine, TrackContext} from '../public'; import { CustomSqlDetailsPanelConfig, CustomSqlTableDefConfig, @@ -35,7 +35,7 @@ export class SimpleSliceTrack extends CustomSqlTableSliceTrack<NamedSliceTrackTy private sqlTableName: string; constructor( - engine: EngineProxy, + engine: Engine, ctx: TrackContext, config: SimpleSliceTrackConfig, ) { diff --git a/ui/src/frontend/slice_args.ts b/ui/src/frontend/slice_args.ts index 97b3b6f95..ec9d609a4 100644 --- a/ui/src/frontend/slice_args.ts +++ b/ui/src/frontend/slice_args.ts @@ -22,7 +22,7 @@ import {exists} from '../base/utils'; import {Actions, AddTrackArgs} from '../common/actions'; import {InThreadTrackSortKey} from '../common/state'; import {ArgNode, convertArgsToTree, Key} from '../controller/args_parser'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {NUM} from '../trace_processor/query_result'; import { VISUALISED_ARGS_SLICE_TRACK_URI, @@ -39,7 +39,7 @@ import {SqlTables} from './sql_table/well_known_tables'; import {assertExists} from '../base/logging'; // Renders slice arguments (key/value pairs) as a subtree. -export function renderArguments(engine: EngineProxy, args: Arg[]): m.Children { +export function renderArguments(engine: Engine, args: Arg[]): m.Children { if (args.length > 0) { const tree = convertArgsToTree(args); return renderArgTreeNodes(engine, tree); @@ -52,10 +52,7 @@ export function hasArgs(args?: Arg[]): args is Arg[] { return exists(args) && args.length > 0; } -function renderArgTreeNodes( - engine: EngineProxy, - args: ArgNode<Arg>[], -): m.Children { +function renderArgTreeNodes(engine: Engine, args: ArgNode<Arg>[]): m.Children { return args.map((arg) => { const {key, value, children} = arg; if (children && children.length === 1) { @@ -80,11 +77,7 @@ function renderArgTreeNodes( }); } -function renderArgKey( - engine: EngineProxy, - key: string, - value?: Arg, -): m.Children { +function renderArgKey(engine: Engine, key: string, value?: Arg): m.Children { if (value === undefined) { return key; } else { @@ -125,7 +118,7 @@ function renderArgKey( } } -async function addVisualisedArg(engine: EngineProxy, argName: string) { +async function addVisualisedArg(engine: Engine, argName: string) { const escapedArgName = argName.replace(/[^a-zA-Z]/g, '_'); const tableName = `__arg_visualisation_helper_${escapedArgName}_slice`; diff --git a/ui/src/frontend/sql/args.ts b/ui/src/frontend/sql/args.ts index 2cf051c27..f36f25323 100644 --- a/ui/src/frontend/sql/args.ts +++ b/ui/src/frontend/sql/args.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import { LONG_NULL, NUM, @@ -42,7 +42,7 @@ export interface Arg { } export async function getArgs( - engine: EngineProxy, + engine: Engine, argSetId: ArgSetId, ): Promise<Arg[]> { const query = await engine.query(` diff --git a/ui/src/frontend/sql/details/details.ts b/ui/src/frontend/sql/details/details.ts index 42b500df2..d24474759 100644 --- a/ui/src/frontend/sql/details/details.ts +++ b/ui/src/frontend/sql/details/details.ts @@ -18,7 +18,7 @@ import {Brand} from '../../../base/brand'; import {Time} from '../../../base/time'; import {exists} from '../../../base/utils'; import {raf} from '../../../core/raf_scheduler'; -import {EngineProxy} from '../../../public'; +import {Engine} from '../../../public'; import {Row, SqlValue} from '../../../trace_processor/query_result'; import {Anchor} from '../../../widgets/anchor'; import {renderError} from '../../../widgets/error'; @@ -202,7 +202,7 @@ export type ValueDesc = // Class responsible for fetching the data and rendering the data. export class Details { constructor( - private engine: EngineProxy, + private engine: Engine, private sqlTable: string, private id: number, schema: {[key: string]: ValueDesc}, @@ -278,14 +278,14 @@ export type RenderedValue = { // async `fetch` step for fetching data and sync `render` step for generating // the vdom. export type SqlIdRefRenderer = { - fetch: (engine: EngineProxy, id: bigint) => Promise<{} | undefined>; + fetch: (engine: Engine, id: bigint) => Promise<{} | undefined>; render: (data: {}) => RenderedValue; }; // Type-safe helper to create a SqlIdRefRenderer, which ensures that the // type returned from the fetch is the same type that renderer takes. export function createSqlIdRefRenderer<Data extends {}>( - fetch: (engine: EngineProxy, id: bigint) => Promise<Data>, + fetch: (engine: Engine, id: bigint) => Promise<Data>, render: (data: Data) => RenderedValue, ): SqlIdRefRenderer { return {fetch, render: render as (data: {}) => RenderedValue}; @@ -451,7 +451,7 @@ class DataController { data?: Data; constructor( - private engine: EngineProxy, + private engine: Engine, private sqlTable: string, private id: number, public sqlIdRefRenderers: {[table: string]: SqlIdRefRenderer}, @@ -652,7 +652,7 @@ function resolve(schema: ValueDesc, data: DataController): ResolvedValue { // Generate the vdom for a given value using the fetched `data`. function renderValue( - engine: EngineProxy, + engine: Engine, key: string, value: ResolvedValue, data: Data, diff --git a/ui/src/frontend/sql/slice.ts b/ui/src/frontend/sql/slice.ts index 050ec4e5c..bf357743b 100644 --- a/ui/src/frontend/sql/slice.ts +++ b/ui/src/frontend/sql/slice.ts @@ -18,7 +18,7 @@ import {BigintMath} from '../../base/bigint_math'; import {Icons} from '../../base/semantic_icons'; import {duration, Time, time} from '../../base/time'; import {exists} from '../../base/utils'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import { LONG, LONG_NULL, @@ -68,7 +68,7 @@ export interface SliceDetails { } async function getUtidAndUpid( - engine: EngineProxy, + engine: Engine, sqlTrackId: number, ): Promise<{utid?: Utid; upid?: Upid}> { const columnInfo = ( @@ -118,7 +118,7 @@ async function getUtidAndUpid( } export async function getSliceFromConstraints( - engine: EngineProxy, + engine: Engine, constraints: SQLConstraints, ): Promise<SliceDetails[]> { const query = await engine.query(` @@ -186,7 +186,7 @@ export async function getSliceFromConstraints( } export async function getSlice( - engine: EngineProxy, + engine: Engine, id: SliceSqlId, ): Promise<SliceDetails | undefined> { const result = await getSliceFromConstraints(engine, { @@ -272,7 +272,7 @@ export interface SliceTreeNode extends SliceDetails { // Get all descendants for a given slice in a tree form. export async function getDescendantSliceTree( - engine: EngineProxy, + engine: Engine, id: SliceSqlId, ): Promise<SliceTreeNode | undefined> { const slice = await getSlice(engine, id); diff --git a/ui/src/frontend/sql/thread_state.ts b/ui/src/frontend/sql/thread_state.ts index e47a5c1e4..7009a6f0e 100644 --- a/ui/src/frontend/sql/thread_state.ts +++ b/ui/src/frontend/sql/thread_state.ts @@ -15,7 +15,7 @@ import m from 'mithril'; import {duration, TimeSpan} from '../../base/time'; -import {EngineProxy} from '../../public'; +import {Engine} from '../../public'; import { LONG, NUM_NULL, @@ -67,7 +67,7 @@ export interface BreakdownByThreadState { // Compute a breakdown of thread states for a given thread for a given time // interval. export async function breakDownIntervalByThreadState( - engine: EngineProxy, + engine: Engine, range: TimeSpan, utid: Utid, ): Promise<BreakdownByThreadState> { diff --git a/ui/src/frontend/sql_table/argument_selector.ts b/ui/src/frontend/sql_table/argument_selector.ts index 29b428154..039cc0ae0 100644 --- a/ui/src/frontend/sql_table/argument_selector.ts +++ b/ui/src/frontend/sql_table/argument_selector.ts @@ -15,7 +15,7 @@ import m from 'mithril'; import {raf} from '../../core/raf_scheduler'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {STR} from '../../trace_processor/query_result'; import {FilterableSelect} from '../../widgets/select'; import {Spinner} from '../../widgets/spinner'; @@ -31,7 +31,7 @@ import {ArgSetIdColumn} from './table_description'; const MAX_ARGS_TO_DISPLAY = 15; interface ArgumentSelectorAttrs { - engine: EngineProxy; + engine: Engine; argSetId: ArgSetIdColumn; tableName: string; constraints: SQLConstraints; diff --git a/ui/src/frontend/sql_table/state.ts b/ui/src/frontend/sql_table/state.ts index 96118f511..2093dad84 100644 --- a/ui/src/frontend/sql_table/state.ts +++ b/ui/src/frontend/sql_table/state.ts @@ -17,7 +17,7 @@ import {SortDirection} from '../../base/comparison_utils'; import {isString} from '../../base/object_utils'; import {sqliteString} from '../../base/string_utils'; import {raf} from '../../core/raf_scheduler'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {NUM, Row} from '../../trace_processor/query_result'; import { constraintsToQueryPrefix, @@ -76,7 +76,7 @@ interface RowCount { } export class SqlTableState { - private readonly engine_: EngineProxy; + private readonly engine_: Engine; private readonly table_: SqlTableDescription; private readonly additionalImports: string[]; @@ -95,7 +95,7 @@ export class SqlTableState { private rowCount?: RowCount; constructor( - engine: EngineProxy, + engine: Engine, table: SqlTableDescription, filters?: Filter[], imports?: string[], diff --git a/ui/src/frontend/sql_table/state_unittest.ts b/ui/src/frontend/sql_table/state_unittest.ts index 91d96a22c..ebb20b5b8 100644 --- a/ui/src/frontend/sql_table/state_unittest.ts +++ b/ui/src/frontend/sql_table/state_unittest.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {Engine, EngineProxy} from '../../trace_processor/engine'; +import {EngineBase} from '../../trace_processor/engine'; import {Column} from './column'; import {SqlTableState} from './state'; @@ -44,14 +44,14 @@ const table: SqlTableDescription = { ], }; -class FakeEngine extends Engine { +class FakeEngine extends EngineBase { id: string = 'TestEngine'; rpcSendRequestBytes(_data: Uint8Array) {} } test('sqlTableState: columnManupulation', () => { - const engine = new EngineProxy(new FakeEngine(), 'test'); + const engine = new FakeEngine(); const state = new SqlTableState(engine, table); const idColumn = { @@ -88,7 +88,7 @@ test('sqlTableState: columnManupulation', () => { }); test('sqlTableState: sortedColumns', () => { - const engine = new EngineProxy(new FakeEngine(), 'test'); + const engine = new FakeEngine(); const state = new SqlTableState(engine, table); // Verify that we have two columns: "id" and "name" and @@ -139,7 +139,7 @@ function normalize(s: string): string { } test('sqlTableState: sqlStatement', () => { - const engine = new EngineProxy(new FakeEngine(), 'test'); + const engine = new FakeEngine(); const state = new SqlTableState(engine, table); // Check the generated SQL statement. diff --git a/ui/src/frontend/sql_table/tab.ts b/ui/src/frontend/sql_table/tab.ts index 42673311b..a91eee45c 100644 --- a/ui/src/frontend/sql_table/tab.ts +++ b/ui/src/frontend/sql_table/tab.ts @@ -25,7 +25,7 @@ import {Popup, PopupPosition} from '../../widgets/popup'; import {Filter, SqlTableState} from './state'; import {SqlTable} from './table'; import {SqlTableDescription, tableDisplayName} from './table_description'; -import {EngineProxy} from '../../public'; +import {Engine} from '../../public'; import {globals} from '../globals'; import {assertExists} from '../../base/logging'; import {uuidv4} from '../../base/uuid'; @@ -58,7 +58,7 @@ export function addSqlTableTab(config: SqlTableTabConfig): void { } // TODO(stevegolton): Find a way to make this more elegant. -function getEngine(): EngineProxy { +function getEngine(): Engine { const engConfig = globals.getCurrentEngine(); const engineId = assertExists(engConfig).id; return assertExists(globals.engines.get(engineId)).getProxy('QueryResult'); diff --git a/ui/src/frontend/sql_table/table.ts b/ui/src/frontend/sql_table/table.ts index d0db6967d..35e620f8b 100644 --- a/ui/src/frontend/sql_table/table.ts +++ b/ui/src/frontend/sql_table/table.ts @@ -16,7 +16,7 @@ import m from 'mithril'; import {isString} from '../../base/object_utils'; import {Icons} from '../../base/semantic_icons'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import {Row} from '../../trace_processor/query_result'; import {Anchor} from '../../widgets/anchor'; import {BasicTable} from '../../widgets/basic_table'; @@ -37,7 +37,7 @@ export interface SqlTableConfig { export class SqlTable implements m.ClassComponent<SqlTableConfig> { private readonly table: SqlTableDescription; - private readonly engine: EngineProxy; + private readonly engine: Engine; private state: SqlTableState; diff --git a/ui/src/frontend/sql_utils.ts b/ui/src/frontend/sql_utils.ts index 891a87680..a78a88a94 100644 --- a/ui/src/frontend/sql_utils.ts +++ b/ui/src/frontend/sql_utils.ts @@ -14,7 +14,7 @@ import {isString} from '../base/object_utils'; import {SortDirection} from '../common/state'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {ColumnType, NUM} from '../trace_processor/query_result'; export interface OrderClause { @@ -111,7 +111,7 @@ export function sqlValueToString(val?: ColumnType): string | undefined { } export async function getTableRowCount( - engine: EngineProxy, + engine: Engine, tableName: string, ): Promise<number | undefined> { const result = await engine.query( diff --git a/ui/src/frontend/thread_and_process_info.ts b/ui/src/frontend/thread_and_process_info.ts index b54cb45bf..2e70b29cd 100644 --- a/ui/src/frontend/thread_and_process_info.ts +++ b/ui/src/frontend/thread_and_process_info.ts @@ -17,7 +17,7 @@ import m from 'mithril'; import {copyToClipboard} from '../base/clipboard'; import {Icons} from '../base/semantic_icons'; import {exists} from '../base/utils'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {NUM, NUM_NULL, STR, STR_NULL} from '../trace_processor/query_result'; import {Anchor} from '../widgets/anchor'; import {MenuItem, PopupMenu2} from '../widgets/menu'; @@ -43,7 +43,7 @@ export interface ProcessInfo { } export async function getProcessInfo( - engine: EngineProxy, + engine: Engine, upid: Upid, ): Promise<ProcessInfo> { const it = ( @@ -137,7 +137,7 @@ export interface ThreadInfo { } export async function getThreadInfo( - engine: EngineProxy, + engine: Engine, utid: Utid, ): Promise<ThreadInfo> { const it = ( diff --git a/ui/src/frontend/thread_state.ts b/ui/src/frontend/thread_state.ts index e912a7ed8..8a3d0ec68 100644 --- a/ui/src/frontend/thread_state.ts +++ b/ui/src/frontend/thread_state.ts @@ -19,7 +19,7 @@ import {duration, Time, time} from '../base/time'; import {exists} from '../base/utils'; import {Actions} from '../common/actions'; import {translateState} from '../common/thread_state'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {LONG, NUM, NUM_NULL, STR_NULL} from '../trace_processor/query_result'; import {CPU_SLICE_TRACK_KIND} from '../core_plugins/cpu_slices'; import {THREAD_STATE_TRACK_KIND} from '../core_plugins/thread_state'; @@ -59,7 +59,7 @@ export interface ThreadState { // Gets a list of thread state objects from Trace Processor with given // constraints. export async function getThreadStateFromConstraints( - engine: EngineProxy, + engine: Engine, constraints: SQLConstraints, ): Promise<ThreadState[]> { const query = await engine.query(` @@ -120,7 +120,7 @@ export async function getThreadStateFromConstraints( } export async function getThreadState( - engine: EngineProxy, + engine: Engine, id: number, ): Promise<ThreadState | undefined> { const result = await getThreadStateFromConstraints(engine, { diff --git a/ui/src/frontend/trace_info_page.ts b/ui/src/frontend/trace_info_page.ts index 485146a3d..c8d754780 100644 --- a/ui/src/frontend/trace_info_page.ts +++ b/ui/src/frontend/trace_info_page.ts @@ -16,7 +16,7 @@ import m from 'mithril'; import {QueryResponse, runQuery} from '../common/queries'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {globals} from './globals'; import {createPage} from './pages'; @@ -29,7 +29,7 @@ interface StatsSectionAttrs { queryId: string; } -function getEngine(name: string): EngineProxy | undefined { +function getEngine(name: string): Engine | undefined { const currentEngine = globals.getCurrentEngine(); if (currentEngine === undefined) return undefined; const engineId = currentEngine.id; diff --git a/ui/src/frontend/track.ts b/ui/src/frontend/track.ts index cd11ce3a4..c6462b00e 100644 --- a/ui/src/frontend/track.ts +++ b/ui/src/frontend/track.ts @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; export interface NewTrackArgs { trackKey: string; - engine: EngineProxy; + engine: Engine; } diff --git a/ui/src/frontend/viz_page.ts b/ui/src/frontend/viz_page.ts index dadb34a97..6145763e5 100644 --- a/ui/src/frontend/viz_page.ts +++ b/ui/src/frontend/viz_page.ts @@ -15,14 +15,14 @@ import m from 'mithril'; import {raf} from '../core/raf_scheduler'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {Editor} from '../widgets/editor'; import {VegaView} from '../widgets/vega_view'; import {globals} from './globals'; import {createPage} from './pages'; -function getEngine(): EngineProxy | undefined { +function getEngine(): Engine | undefined { const engineId = globals.getCurrentEngine()?.id; if (engineId === undefined) { return undefined; @@ -32,7 +32,7 @@ function getEngine(): EngineProxy | undefined { } let SPEC = ''; -let ENGINE: EngineProxy | undefined = undefined; +let ENGINE: Engine | undefined = undefined; export const VizPage = createPage({ oncreate() { diff --git a/ui/src/plugins/dev.perfetto.AndroidLongBatteryTracing/index.ts b/ui/src/plugins/dev.perfetto.AndroidLongBatteryTracing/index.ts index 2a22affc5..8f360b4af 100644 --- a/ui/src/plugins/dev.perfetto.AndroidLongBatteryTracing/index.ts +++ b/ui/src/plugins/dev.perfetto.AndroidLongBatteryTracing/index.ts @@ -13,7 +13,7 @@ // limitations under the License. import {Plugin, PluginContextTrace, PluginDescriptor} from '../../public'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; import { SimpleSliceTrack, SimpleSliceTrackConfig, @@ -1694,7 +1694,7 @@ class AndroidLongBatteryTracing implements Plugin { ); } - async findFeatures(e: EngineProxy): Promise<Set<string>> { + async findFeatures(e: Engine): Promise<Set<string>> { const features = new Set<string>(); const addFeatures = async (q: string) => { diff --git a/ui/src/plugins/dev.perfetto.AndroidNetwork/index.ts b/ui/src/plugins/dev.perfetto.AndroidNetwork/index.ts index 9cb840508..34fd08712 100644 --- a/ui/src/plugins/dev.perfetto.AndroidNetwork/index.ts +++ b/ui/src/plugins/dev.perfetto.AndroidNetwork/index.ts @@ -14,14 +14,14 @@ import {Plugin, PluginContextTrace, PluginDescriptor} from '../../public'; import {addDebugSliceTrack} from '../../public'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; class AndroidNetwork implements Plugin { // Adds a debug track using the provided query and given columns. The columns // must be start with ts, dur, and a name column. The name column and all // following columns are shown as arguments in slice details. async addSimpleTrack( - engine: EngineProxy, + engine: Engine, trackName: string, tableOrQuery: string, columns: string[], diff --git a/ui/src/plugins/dev.perfetto.AndroidPerf/index.ts b/ui/src/plugins/dev.perfetto.AndroidPerf/index.ts index a53ff20f7..25f11f413 100644 --- a/ui/src/plugins/dev.perfetto.AndroidPerf/index.ts +++ b/ui/src/plugins/dev.perfetto.AndroidPerf/index.ts @@ -18,11 +18,11 @@ import { PluginContextTrace, PluginDescriptor, } from '../../public'; -import {EngineProxy} from '../../trace_processor/engine'; +import {Engine} from '../../trace_processor/engine'; class AndroidPerf implements Plugin { async addAppProcessStartsDebugTrack( - engine: EngineProxy, + engine: Engine, reason: string, sliceName: string, ): Promise<void> { diff --git a/ui/src/public/index.ts b/ui/src/public/index.ts index f3e433853..7fb2e4416 100644 --- a/ui/src/public/index.ts +++ b/ui/src/public/index.ts @@ -20,10 +20,10 @@ import {Migrate, Store} from '../base/store'; import {ColorScheme} from '../core/colorizer'; import {LegacySelection} from '../common/state'; import {PanelSize} from '../frontend/panel'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {UntypedEventSet} from '../core/event_set'; -export {EngineProxy} from '../trace_processor/engine'; +export {Engine} from '../trace_processor/engine'; export { LONG, LONG_NULL, @@ -344,7 +344,7 @@ export interface DetailsPanel { // currently loaded trace. Passed to trace-relevant hooks on a plugin instead of // PluginContext. export interface PluginContextTrace extends PluginContext { - readonly engine: EngineProxy; + readonly engine: Engine; // Control over the main timeline. timeline: { diff --git a/ui/src/trace_processor/engine.ts b/ui/src/trace_processor/engine.ts index b234c169a..90901c572 100644 --- a/ui/src/trace_processor/engine.ts +++ b/ui/src/trace_processor/engine.ts @@ -13,7 +13,6 @@ // limitations under the License. import {defer, Deferred} from '../base/deferred'; -import {Disposable} from '../base/disposable'; import {assertExists, assertTrue} from '../base/logging'; import {duration, Span, Time, time, TimeSpan} from '../base/time'; import { @@ -42,6 +41,7 @@ import { } from './query_result'; import TPM = TraceProcessorRpc.TraceProcessorMethod; +import {Disposable} from '../base/disposable'; export interface LoadingTracker { beginLoading(): void; @@ -66,6 +66,19 @@ export interface TraceProcessorConfig { ftraceDropUntilAllCpusValid: boolean; } +export interface Engine { + execute(sqlQuery: string, tag?: string): Promise<QueryResult> & QueryResult; + query(sqlQuery: string, tag?: string): Promise<QueryResult>; + getCpus(): Promise<number[]>; + getNumberOfGpus(): Promise<number>; + getTracingMetadataTimeBounds(): Promise<Span<time, duration>>; + computeMetric( + metrics: string[], + format: 'json' | 'prototext' | 'proto', + ): Promise<string | Uint8Array>; + readonly isAlive: boolean; +} + // Abstract interface of a trace proccessor. // This is the TypeScript equivalent of src/trace_processor/rpc.h. // There are two concrete implementations: @@ -77,7 +90,7 @@ export interface TraceProcessorConfig { // 1. Implement the abstract rpcSendRequestBytes() function, sending the // proto-encoded TraceProcessorRpc requests to the TraceProcessor instance. // 2. Call onRpcResponseBytes() when response data is received. -export abstract class Engine { +export abstract class EngineBase implements Engine { abstract readonly id: string; private _cpus?: number[]; private _numGpus?: number; @@ -93,6 +106,7 @@ export abstract class Engine { private pendingComputeMetrics = new Array<Deferred<string | Uint8Array>>(); private pendingReadMetatrace?: Deferred<DisableAndReadMetatraceResult>; private _isMetatracingEnabled = false; + readonly isAlive = false; constructor(tracker?: LoadingTracker) { this.loadingTracker = tracker ? tracker : new NullLoadingTracker(); @@ -502,10 +516,9 @@ export abstract class Engine { } } -// Lightweight wrapper over Engine exposing only `query` method and annotating -// all queries going through it with a tag. -export class EngineProxy implements Disposable { - private engine: Engine; +// Lightweight engine proxy which annotates all queries with a tag +export class EngineProxy implements Engine, Disposable { + private engine: EngineBase; private tag: string; private _isAlive: boolean; @@ -513,7 +526,7 @@ export class EngineProxy implements Disposable { return this._isAlive; } - constructor(engine: Engine, tag: string) { + constructor(engine: EngineBase, tag: string) { this.engine = engine; this.tag = tag; this._isAlive = true; @@ -557,6 +570,10 @@ export class EngineProxy implements Disposable { return this.engine.getNumberOfGpus(); } + async getTracingMetadataTimeBounds(): Promise<Span<time, bigint>> { + return this.engine.getTracingMetadataTimeBounds(); + } + get engineId(): string { return this.engine.id; } diff --git a/ui/src/trace_processor/http_rpc_engine.ts b/ui/src/trace_processor/http_rpc_engine.ts index dfd9bc890..720e2b63c 100644 --- a/ui/src/trace_processor/http_rpc_engine.ts +++ b/ui/src/trace_processor/http_rpc_engine.ts @@ -15,7 +15,7 @@ import {fetchWithTimeout} from '../base/http_utils'; import {assertExists} from '../base/logging'; import {StatusResult} from '../protos'; -import {Engine, LoadingTracker} from '../trace_processor/engine'; +import {EngineBase, LoadingTracker} from '../trace_processor/engine'; const RPC_CONNECT_TIMEOUT_MS = 2000; @@ -25,7 +25,7 @@ export interface HttpRpcState { failure?: string; } -export class HttpRpcEngine extends Engine { +export class HttpRpcEngine extends EngineBase { readonly id: string; errorHandler: (err: string) => void = () => {}; private requestQueue = new Array<Uint8Array>(); diff --git a/ui/src/trace_processor/wasm_engine_proxy.ts b/ui/src/trace_processor/wasm_engine_proxy.ts index 42740e234..163fac503 100644 --- a/ui/src/trace_processor/wasm_engine_proxy.ts +++ b/ui/src/trace_processor/wasm_engine_proxy.ts @@ -13,7 +13,7 @@ // limitations under the License. import {assertExists, assertTrue} from '../base/logging'; -import {Engine, LoadingTracker} from '../trace_processor/engine'; +import {EngineBase, LoadingTracker} from '../trace_processor/engine'; let bundlePath: string; let idleWasmWorker: Worker; @@ -47,7 +47,7 @@ export function resetEngineWorker(): MessagePort { * This implementation of Engine uses a WASM backend hosted in a separate * worker thread. */ -export class WasmEngineProxy extends Engine { +export class WasmEngineProxy extends EngineBase { readonly id: string; private port: MessagePort; diff --git a/ui/src/widgets/vega_view.ts b/ui/src/widgets/vega_view.ts index 97d982674..39be606f7 100644 --- a/ui/src/widgets/vega_view.ts +++ b/ui/src/widgets/vega_view.ts @@ -20,7 +20,7 @@ import {Disposable} from '../base/disposable'; import {getErrorMessage} from '../base/errors'; import {isString, shallowEquals} from '../base/object_utils'; import {SimpleResizeObserver} from '../base/resize_observer'; -import {EngineProxy} from '../trace_processor/engine'; +import {Engine} from '../trace_processor/engine'; import {QueryError} from '../trace_processor/query_result'; import {scheduleFullRedraw} from '../widgets/raf'; import {Spinner} from '../widgets/spinner'; @@ -45,7 +45,7 @@ export interface VegaViewData { interface VegaViewAttrs { spec: string; data: VegaViewData; - engine?: EngineProxy; + engine?: Engine; } // VegaWrapper is in exactly one of these states: @@ -62,10 +62,10 @@ enum Status { } class EngineLoader implements vega.Loader { - private engine?: EngineProxy; + private engine?: Engine; private loader: vega.Loader; - constructor(engine: EngineProxy | undefined) { + constructor(engine: Engine | undefined) { this.engine = engine; this.loader = vega.loader(); } @@ -125,7 +125,7 @@ class VegaWrapper { private pending?: Promise<vega.View>; private _status: Status; private _error?: string; - private _engine?: EngineProxy; + private _engine?: Engine; constructor(dom: Element) { this.dom = dom; @@ -155,7 +155,7 @@ class VegaWrapper { this.updateView(); } - set engine(engine: EngineProxy | undefined) { + set engine(engine: Engine | undefined) { this._engine = engine; } |