marp-team / marp-vscode

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode
MIT License
1.55k stars 72 forks source link

Abnormally high CPU usage when editing files quickly #449

Closed miyaji255 closed 7 months ago

miyaji255 commented 8 months ago

Version of Marp Tool

Marp for VS Code v2.8.0

Operating System

Windows

Environment

How to reproduce

  1. Repeat the code change quickly. (e.g. alt+arrow keys in succession)
  2. Temporary increase in CPU usage
  3. VS Code runs slower

This is especially noticeable when markdown.marp.enableHtml is true.

Expected behavior

CPU utilization is within the sensible range.

Actual behavior

On notebooks and other less powerful computers, CPU utilization rises to about 50%.

Additional information

I assume that even after the code change, the conversion from the previous change has not been canceled.

miyaji255 commented 8 months ago

The more external URLs you register in markdown.marp.themes, the slower it will run.

yhatt commented 8 months ago

Since Marp uses the Markdown preview mechanism provided by VS Code, we are skeptical whether this issue is specific to Marp. Please verify if the CPU usage problem is indeed caused by the Marp for VS Code extension.

For instance, there might be other extensions or non-extension processes in VS Code that could be consuming CPU resources. If you disable all extensions except Marp, does the issue still occur?

Furthermore, please check if the CPU usage increases in the default Markdown preview of VS Code.

If it is surely confirmed that the Marp extension is the cause, please share the CPU profiles during the moments when the CPU usage is high. https://github.com/microsoft/vscode/wiki/Performance-Issues#profiling-the-shared-process

miyaji255 commented 8 months ago

I am unable to save a Performance Profile due to a bug in Chromium.

https://github.com/electron/electron/issues/39818 https://github.com/microsoft/vscode/issues/200668

miyaji255 commented 8 months ago

This is a screenshot of the Performance Profile. スクリーンショット 2023-12-14 221924

After disabling each of the extensions, we found that it occurs when Markdown All in One and Marp are enabled at the same time.

CPU usage did not increase when editing non-Marp Markdown files with Markdown All in One enabled.

yhatt commented 8 months ago

The documentation of Markdown All in One extension seems to have mentioned about the incompatibility with Marp for VS Code. https://markdown-all-in-one.github.io/docs/guide/compatibility.html#incompatibility

According to the documentation, that is especially concerned about the outline extension by Marp (microsoft/vscode#132741). You might mitigate compatibillity problem to disable Marp's outline extension markdown.marp.outlineExtension.

FYI I have been using the two extensions at the same time for a long time, and I have not experienced any clear problems about compatibillity.

miyaji255 commented 8 months ago

Thank you for your research. Disabling the markdown.marp.outlineExtension did not change the problem, it only occurs when I write HTML tags, so I will disabling Markdown All in One when I write HTML to create slides.

yhatt commented 7 months ago

Close for housekeeping, because still cannot determine whether this problem is caused by Marp for VS Code. That may still dependent on HTML contents by the user.