perfetto-ui: Only do logs queries when there are logs
We don't currently have query queuing handled properly for logs.
(It is handled differently than any other track)
This needs to be fixed in a follow up CL but in the mean time
let's avoid doing any logs queries when we don't have logs in
the trace.
Now in the example trace when panning and zooming the number of
queries never goes above X. (63 for me)
Change-Id: Ie2317d365368928ec0031d2a499c1818345a79c7
diff --git a/ui/src/controller/logs_controller.ts b/ui/src/controller/logs_controller.ts
index 748c5e8..abe5a9e 100644
--- a/ui/src/controller/logs_controller.ts
+++ b/ui/src/controller/logs_controller.ts
@@ -147,6 +147,7 @@
private engine: Engine;
private span: TimeSpan;
private pagination: Pagination;
+ private hasLogs = false;
constructor(args: LogsControllerArgs) {
super('main');
@@ -154,23 +155,27 @@
this.engine = args.engine;
this.span = new TimeSpan(0, 10);
this.pagination = new Pagination(0, 0);
- this.publishHasAnyLogs();
- }
-
- async publishHasAnyLogs() {
- const result = await this.engine.queryOneRow(`
- select count(*) from android_logs
- `);
- const exists = result[0] > 0;
- this.app.publish('TrackData', {
- id: LogExistsKey,
- data: {
- exists,
- },
+ this.hasAnyLogs().then(exists => {
+ this.hasLogs = exists;
+ this.app.publish('TrackData', {
+ id: LogExistsKey,
+ data: {
+ exists,
+ },
+ });
});
}
+ async hasAnyLogs() {
+ const result = await this.engine.queryOneRow(`
+ select count(*) from android_logs
+ `);
+ return result[0] > 0;
+ }
+
run() {
+ if (!this.hasLogs) return;
+
const traceTime = this.app.state.frontendLocalState.visibleState;
const newSpan = new TimeSpan(traceTime.startSec, traceTime.endSec);
const oldSpan = this.span;