-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to track lsp perf on language client level #2996
Add API to track lsp perf on language client level #2996
Conversation
// @akaroml @Eskibear @CsCherrYY pls help a review on the API design as well. |
src/TracingLanguageClient.ts
Outdated
sendRequest<R>(method: string, token?: CancellationToken): Promise<R>; | ||
sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>; | ||
sendRequest(method: any, ...args) { | ||
const startAt: number = Date.now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to use performance.now()
. See: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
Also, Date.now() may have been impacted by system and user clock adjustments, clock skew, etc. as it is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on the system clock. The performance.now() method on the other hand is relative to the timeOrigin property which is a monotonic clock: its current time never decreases and isn't subject to adjustments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. Good to know the new API.
The data will like textDocument/completion - 1359.5962999993935 ms
with performance.now api. Then the downstream tracer can decide whether to convert the floating point number to integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR provides an API to easily trace the lsp request performance.
initialize
request on languageClient.start()sendRequest(...)
Here is a sample code on how to use this API: