microsoft / microsoft/vscode-cpptools

macOS: High CPU Usage (looping `update_file_if_needed`)

Open
#8,124 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service performance symlinks
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Language Service

Describe the bug

  • OS and Version:
    Screen Shot 2021-09-09 at 11 00 41 am
  • VS Code Version:
    Screen Shot 2021-09-09 at 11 00 56 am
  • C/C++ Extension Version:
    v1.6.0

Sometime after starting vscode, the cpptools process will jump to 100% CPU usage and stay there until the windows is reloaded.
The project is for embedded devices, and is therefore using a cross-compiler (arm-none-eabi-gcc). Intellisense configuration is through an autogenerated compile_commands.json. The project is based on Zephyr RTOS (https://github.com/zephyrproject-rtos/zephyr). The root folder (ignoring compiler headers) is approximately 40k files.

Code sample and logs

  • Configurations in c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Zephyr",
            "cStandard": "c99",
            "compilerPath": "/Users/<user>/code/gcc-arm-none-eabi/bin/arm-none-eabi-gcc",
            "intelliSenseMode": "gcc-x64",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "includePath": [
                "zephyr/include",
                "${workspaceFolder}/build/zephyr/include/generated"
            ]
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
    "C_Cpp.loggingLevel": "7",
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/x86/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/arm64/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/arm/aarch32/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/arc/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/nios2/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/riscv/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/xtensa/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/posix/arch.h
  Same time stamp: 1630475297
update_file_if_needed: /Users/<user>/zephyr/zephyr/include/arch/sparc/arch.h
  Same time stamp: 1630475297

Over a minute or so of just watching the logs, there were approximately 400 thousand lines like the above.
Not all files were being checked. Files that were checked were checked about 80 times each.

Additional context

Call stack of cpptools process.

Screen Shot 2021-09-09 at 11 01 50 am

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cpptools process call stack and the repeated update_file_if_needed diagnostics from C/C++: Log Diagnostics. Reproduce on macOS using the Zephyr workspace, arm-none-eabi-gcc, and autogenerated compile_commands.json; done means the repeated file checks stop and cpptools no longer sustains 100% CPU.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.