Add perf marks for query execution (#22082)

This commit is contained in:
Hai Cao
2023-03-02 11:36:29 -08:00
committed by GitHub
parent 9033ed5583
commit 20969bf244
9 changed files with 99 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ import * as azdata from 'azdata';
import { Event, Emitter } from 'vs/base/common/event';
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
import { MainThreadDataProtocolShape, ExtHostDataProtocolShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { MainThreadDataProtocolShape, ExtHostDataProtocolShape, MainThreadPerfShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { DataProviderType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IURITransformer } from 'vs/base/common/uriIpc';
import { URI, UriComponents } from 'vs/base/common/uri';
@@ -24,6 +24,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
readonly onDidChangeLanguageFlavor: Event<azdata.DidChangeLanguageFlavorParams> = this._onDidChangeLanguageFlavor.event;
private _proxy: MainThreadDataProtocolShape;
private _perfProxy: MainThreadPerfShape;
private static _handlePool: number = 0;
private _adapter = new Map<number, azdata.DataProvider>();
@@ -38,6 +39,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
) {
super();
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadDataProtocol);
this._perfProxy = mainContext.getProxy(SqlMainContext.MainThreadPerf);
}
private _getTransformedUri(uri: string, transformMethod: (uri: UriComponents) => UriComponents): string {
@@ -291,19 +293,22 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
if (this.uriTransformer) {
ownerUri = this._getTransformedUri(ownerUri, this.uriTransformer.transformIncoming);
}
this._perfProxy.$mark(`sql/query/${ownerUri}/ext_$runQuery`);
return this._resolveProvider<azdata.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions);
}
override $runQueryStatement(handle: number, ownerUri: string, line: number, column: number): Thenable<void> {
this._perfProxy.$mark(`sql/query/${ownerUri}/ext_$runQueryStatement`);
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryStatement(ownerUri, line, column);
}
override $runQueryString(handle: number, ownerUri: string, queryString: string): Thenable<void> {
this._perfProxy.$mark(`sql/query/${ownerUri}/ext_$runQueryString`);
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryString(ownerUri, queryString);
}
override $runQueryAndReturn(handle: number, ownerUri: string, queryString: string): Thenable<azdata.SimpleExecuteResult> {
this._perfProxy.$mark(`sql/query/${ownerUri}/ext_$runQueryAndReturn`);
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryAndReturn(ownerUri, queryString);
}
@@ -349,6 +354,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
if (this.uriTransformer) {
result.ownerUri = this._getTransformedUri(result.ownerUri, this.uriTransformer.transformOutgoing);
}
this._perfProxy.$mark(`sql/query/${result.ownerUri}/ext_$onQueryComplete`);
// clear messages to maintain the order of things
if (this.messageRunner.isScheduled()) {
this.messageRunner.cancel();