bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Extension causes high cpu load

Open erreyi opened this issue 3 years ago • 2 comments

  • Issue Type: Performance
  • Extension Name: vscode-bicep
  • Extension Version: 0.9.1
  • OS Version: Darwin arm64 21.6.0
  • VS Code version: 1.70.0

:warning: Make sure to attach this file from your home-directory: :warning:file:///var/folders/cq/ph9fgfjd4wzgp_7vpqwl90gr0000gn/T/ms-azuretools.vscode-bicep-unresponsive.cpuprofile.txt

Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load

erreyi avatar Aug 09 '22 19:08 erreyi

@erreyi - please could you upload the file from the error (/var/folders/cq/ph9fgfjd4wzgp_7vpqwl90gr0000gn/T/ms-azuretools.vscode-bicep-unresponsive.cpuprofile.txt).

If you don't want to share it publicly, feel free to email to me (antmarti at microsoft dot com)

anthony-c-martin avatar Aug 09 '22 21:08 anthony-c-martin

Here's what the profile looks like: image And the method in question:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const deployParamsPattern = new RegExp('.*"token":\\s*"(?<token>.*)"');
export function removePropertiesWithPossibleUserInfoInDeployParams(
  value: string
): string {
  const matches = deployParamsPattern.exec(value);

  if (matches) {
    const groups = matches.groups;

    if (groups) {
      const token = groups["token"];

      return value.replace(token, "<REDACTED: token>");
    }
  }

  return value;
}

The regex could be optimized (pre-compile, remove the ".*" from the beginning), although it seems unlikely to be causing serious performance issues.

StephenWeatherford avatar Sep 02 '22 21:09 StephenWeatherford

@erreyi Does this happen frequently? Was it a one-time event? Thanks.

StephenWeatherford avatar Sep 02 '22 21:09 StephenWeatherford

Hi erreyi, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! :smile: :mechanical_arm:

ghost avatar May 24 '23 04:05 ghost