mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #463] markdownlint takes absurdly long to parse a 27,000 line table due to work for each inline incorrectly processing the entire table #2230
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2230
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fireattack on GitHub (Nov 22, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/463
STR:
*Note: I see this bug even without opening an MD file. But a long MD file is what makes it easier to reproduce.
Expected
a popup from TPT to ask you to input query
Observed
It shows "activating extensions..." at status bar for a while, then nothing happens. No popup. If I click "activating extensions" during the time, it shows mardownlint is "unresponsive".
Afterwards, markdownlint freezes (no longer recognize lighting errors) until restarting.
Tested on newest stable VS Code and Insiders
See also: https://github.com/qcz/vscode-text-power-tools/issues/29
@DavidAnson commented on GitHub (Nov 22, 2021):
Running a TPT command leads VS Code to report markdownlint is unresponsive? I've seen them mis-report this before. Please follow the steps they give to capture a stack trace - that should help identify the issue. Also, if the slowdown does not happen when TPT is not used, it's a pretty good indication that's responsible.
@DavidAnson commented on GitHub (Nov 22, 2021):
The message "activating extensions" is another clue - markdownlint will have already been activated if you are editing a Markdown file. You can force a linting error to verify that before running the TPT command.
@fireattack commented on GitHub (Nov 22, 2021):
When that happens (after I tried to use a TPT command), markdownlint actually freezes. The document (or even a different file) will no longer show new linting error anymore:
To make it worse, it sometimes happens even without using TPT.
As for debugging the issue, I'll be frank I don't know how to do it :/
@fireattack commented on GitHub (Nov 23, 2021):
Here is a GIF

@DavidAnson commented on GitHub (Nov 23, 2021):
Please describe the steps to reproduce the problem reliably - ideally without TPT. (The GIF is hard to tell what's going on.)
If VS Code is prompting you to collect diagnostics like this, please attach them: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
If you can't find reproducible steps, here are ways to narrow down the issue on your machine: https://github.com/Microsoft/vscode/wiki/Performance-Issues#profile-the-running-extensions
@fireattack commented on GitHub (Nov 23, 2021):
The reproducible steps are already listed in original post. You do need TPT installed to trigger the issue. Feel free to test it to see if you can reproduce it or not. (I edited it a little bit to emphasize that markdownlint will freeze afterwards.)
The GIF is just showing that after running command in TPT, markdownlint freezes and can no longer show new linting error.
(Sometimes you don't need to actually run commands in TPT to cause issue, just having it installed; but using command more reliably causes the issue.)
@fireattack commented on GitHub (Nov 23, 2021):
The profile is attached.
CPU-20211123T033253.375Z.cpuprofile.txt
@DavidAnson commented on GitHub (Nov 24, 2021):
Thanks! Your trace shows an unreasonable amount of time being spent in markdownlint's
helpers.emphasisMarkersInContentfunction which is used exclusively byMD037/no-space-in-emphasis. It doesn't seem to be stuck, but rather spending all its time in the "search code spans" phase splitting code withnewLineReand runningemphasisMarkersRe.Interestingly, if I weren't looking at your issue, I was going to be looking at this function anyway because it relates to a commit I did yesterday. I'll see if I can reproduce the issue using the file you link to above.
@DavidAnson commented on GitHub (Nov 24, 2021):
Trying to load that page into https://dlaa.me/markdownlint/ takes a very long time, so I think TPT is probably innocent and markdownlint has an infinite loop or major performance problem associated with the structure of that file. Thanks again, I'll continue to look into this.
@DavidAnson commented on GitHub (Nov 24, 2021):
Oh no... The pattern of calling
forEachInlineCodeSpan(tokenLines.join("\n"), ...)is very problematic at the moment. In this case,tokencorresponds to one of the cells of the table andtokenLinesincludes all 26695 lines of the table. Each line contains 2-4 tokens depending on the scenario, and the entire table is re-scanned for every token. Not good. This is fixable, but it's an issue with the library and I'll transfer the issue there.