Skip to content

Perf in logs#41319

Closed
zarend wants to merge 1 commit intoangular:masterfrom
zarend:perf-in-logs
Closed

Perf in logs#41319
zarend wants to merge 1 commit intoangular:masterfrom
zarend:perf-in-logs

Conversation

@zarend
Copy link
Copy Markdown
Contributor

@zarend zarend commented Mar 22, 2021

feat(language-service): add perf tracing to LanguageService

Adds perf tracing for the public methods in LanguageService. If the log level is verbose or higher,
trace performance results to the tsServer logger. This logger is implemented on the extension side
in angular/vscode-ng-language-service.

how to view perf tracing in vscode.

  1. set angular log level to verbose Screen Shot 2021-03-19 at 10 34 19 AM
  2. Run vscode action: "Open Angular Server Log" image
  3. Search for lines matching LanguageService#

grepping for log files

while testing, I saved the patch to the angular server log to an environment variable and use grep to search for perf tracing.

# grep --text LanguageService# $NG_SERVER_LOG

Test plan

This PR was tested manually against a local build of the vscode extension. I made sure that perf tracing showed up for each public method in LanguageService
image

@zarend zarend requested review from alxhub and atscott March 22, 2021 21:21
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 22, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Mar 22, 2021
@pullapprove pullapprove bot requested a review from josephperrott March 22, 2021 21:21
@zarend zarend added action: review The PR is still awaiting reviews from at least one requested reviewer area: language-service Issues related to Angular's VS Code language service labels Mar 22, 2021
@ngbot ngbot bot added this to the Backlog milestone Mar 22, 2021
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 24, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.


const logger = this.project.projectService.logger;
if (logger.hasLevel(ts.server.LogLevel.verbose)) {
logger.perftrc(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: this is where we do the perf tracing.

* @param p callback to be run synchronously with an instance of the `NgCompiler` as argument
* @return the result of running the `p` callback
*/
private withCompilerAndPerfTracing<T>(callerName: string, p: (compiler: NgCompiler) => T): T {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of perf tracing is recording the time it takes each actual Language Service operation to take place. So in addition to appending the results, this function should actually execute p in a perf phase associated with the operation in question. Maybe consider taking that PerfPhase instead of callerName, and using the phase name for the logger.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it's make more sense to leverage the existing api of the perf recorder. I'll fix this.

Copy link
Copy Markdown
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if you add tests / explain why you can't add tests to this PR

@zarend zarend added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 25, 2021
@zarend
Copy link
Copy Markdown
Contributor Author

zarend commented Mar 29, 2021

@alxhub @atscott , I've made fixes to this PR, and it's ready for your eyes again 👀

Here's the changes since you last reviewed

  • added a unit test
  • log perf phases instead of LanguageService method names

@zarend zarend requested review from alxhub and atscott March 29, 2021 22:18
@zarend zarend added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 29, 2021
@josephperrott josephperrott removed their request for review March 30, 2021 18:34
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is particularly useful to include, we can drop it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I don't feel strongly about logging this 👍

Adds perf tracing for the public methods in LanguageService. If the log level is verbose or higher,
trace performance results to the tsServer logger. This logger is implemented on the extension side
in angular/vscode-ng-language-service.
@zarend zarend added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 31, 2021
@zarend
Copy link
Copy Markdown
Contributor Author

zarend commented Mar 31, 2021

presubmit cl

@zarend zarend added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Mar 31, 2021
@zarend zarend removed the request for review from atscott March 31, 2021 14:58
@alxhub alxhub added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Mar 31, 2021
@alxhub alxhub closed this in 90f85da Mar 31, 2021
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
…41319)

Adds perf tracing for the public methods in LanguageService. If the log level is verbose or higher,
trace performance results to the tsServer logger. This logger is implemented on the extension side
in angular/vscode-ng-language-service.

PR Close angular#41319
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service cla: yes target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants