[GH-ISSUE #821] What's happening with performances ? #2387

Closed
opened 2026-03-07 20:07:18 +03:00 by kerem · 12 comments
Owner

Originally created by @nvuillam on GitHub (May 17, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/821

Since 0.34, linting 230 files takes more than 200 seconds whereas with 0.33 it was 6 seconds :(

Note: markdownlint is called with the list of files as input parameter, ex: markdownlint file1.md file2.md path/to/my/file3.md

I'm thinking about downgrading markdownlint in MegaLinter... or maybe there is some fix to perform ? :)

Many thanks for your linter and for your support !

  • With v0.33.0

image
image

  • With 0.34.0
    image

image

Originally created by @nvuillam on GitHub (May 17, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/821 Since 0.34, linting 230 files takes more than 200 seconds whereas with 0.33 it was 6 seconds :( Note: markdownlint is called with the list of files as input parameter, ex: `markdownlint file1.md file2.md path/to/my/file3.md` I'm thinking about downgrading markdownlint in MegaLinter... or maybe there is some fix to perform ? :) Many thanks for your linter and for your support ! - With v0.33.0 ![image](https://github.com/DavidAnson/markdownlint/assets/17500430/0ebdab4f-9f36-40e4-a947-09a6f6c3fd3e) ![image](https://github.com/DavidAnson/markdownlint/assets/17500430/9f5047cd-1bbe-4335-93c5-af9b18df8b76) - With 0.34.0 ![image](https://github.com/DavidAnson/markdownlint/assets/17500430/11de7da0-ba99-4633-b1a2-6b874fc36908) ![image](https://github.com/DavidAnson/markdownlint/assets/17500430/d9e0fa5b-bf88-4a70-b6fa-09c567d68ae7)
kerem 2026-03-07 20:07:18 +03:00
Author
Owner

@DavidAnson commented on GitHub (May 17, 2023):

The latest version of markdownlint uses a second parser, micromark, for some of its rules. micromark includes positional information that is missing from the original parser, markdownit-it. Unfortunately, micromark is not as fast - and during this transition time, running two parsers isn't helping. The good news is that rules I migrated to micromark were all improved by doing so. Additionally, I spent time reviewing micromark code and got a PR merged there which will give something like 10 or 15% improvement once released. micromark also rewrote and improved table parsing for a 10% improvement and that will be part of the next markdownlint release. I was well aware of this performance impact and I didn't take the decision lightly, but correctness and accuracy improvements coming from micromark seem worthwhile. I look at performance pretty regularly and if you have suggestions, I am happy to consider them. The short term goal is to finish migrating to micromark, at which point I will be able to stop running markdown-it (unless custom rules need it). That should help improve performance, but I don't think it will return to where it was due to the relative speeds of the two parsers.

<!-- gh-comment-id:1552217541 --> @DavidAnson commented on GitHub (May 17, 2023): The latest version of markdownlint uses a second parser, micromark, for some of its rules. micromark includes positional information that is missing from the original parser, markdownit-it. Unfortunately, micromark is not as fast - and during this transition time, running two parsers isn't helping. The good news is that rules I migrated to micromark were all improved by doing so. Additionally, I spent time reviewing micromark code and got a PR merged there which will give something like 10 or 15% improvement once released. micromark also rewrote and improved table parsing for a 10% improvement and that will be part of the next markdownlint release. I was well aware of this performance impact and I didn't take the decision lightly, but correctness and accuracy improvements coming from micromark seem worthwhile. I look at performance pretty regularly and if you have suggestions, I am happy to consider them. The short term goal is to finish migrating to micromark, at which point I will be able to stop running markdown-it (unless custom rules need it). That should help improve performance, but I don't think it will return to where it was due to the relative speeds of the two parsers.
Author
Owner

@DavidAnson commented on GitHub (May 17, 2023):

Re-reading your comment, the slow down you are seeing seems more dramatic than I would expect. If you are able to share the repository or a set of files to reproduce that level of slow down, I can have a look at whether it's triggering some kind of edge case. Thank you!

<!-- gh-comment-id:1552218949 --> @DavidAnson commented on GitHub (May 17, 2023): Re-reading your comment, the slow down you are seeing seems more dramatic than I would expect. If you are able to share the repository or a set of files to reproduce that level of slow down, I can have a look at whether it's triggering some kind of edge case. Thank you!
Author
Owner

@DavidAnson commented on GitHub (May 17, 2023):

One more follow up, if you haven't tried using markdownlint-cli2, it is generally faster than markdownlint-cli, and that may allow you to recover some time.

<!-- gh-comment-id:1552220110 --> @DavidAnson commented on GitHub (May 17, 2023): One more follow up, if you haven't tried using markdownlint-cli2, it is generally faster than markdownlint-cli, and that may allow you to recover some time.
Author
Owner

@nvuillam commented on GitHub (May 17, 2023):

@DavidAnson thanks for your quick reply:)

This is running on own MegaLinter repository using beta version :)

https://github.com/oxsecurity/megalinter/actions/runs/5008752311/jobs/8976954079?pr=2649

This is indeed dramatic, as even if we parallelize and prioritize linter jobs, Github Action servers has only 2 cores, so it locks one of them dring markdownlint process, and increase a lot the total linting time :/

I had a PR about markdownlint-cli2 , but I wasn't convinced of the necessity to replace markdownlint-cli... and if the performance issue is in the core markdownlint, it probably won't change a lot :/

<!-- gh-comment-id:1552221350 --> @nvuillam commented on GitHub (May 17, 2023): @DavidAnson thanks for your quick reply:) This is running on own MegaLinter repository using beta version :) https://github.com/oxsecurity/megalinter/actions/runs/5008752311/jobs/8976954079?pr=2649 This is indeed dramatic, as even if we parallelize and prioritize linter jobs, Github Action servers has only 2 cores, so it locks one of them dring markdownlint process, and increase a lot the total linting time :/ I had a PR about markdownlint-cli2 , but I wasn't convinced of the necessity to replace markdownlint-cli... and if the performance issue is in the core markdownlint, it probably won't change a lot :/
Author
Owner

@DavidAnson commented on GitHub (May 18, 2023):

I have good news! Your project's heavy use of tables causes it to run into some really, really bad performance in micromark's table code. They improved that code in a recent release (which is already used by markdownlint in its next branch). If I swap in the better table code, markdownlint performance is much closer to what it was in the previous version.

Below are some quick timings I did in a GitHub Codespace (to approximate the same hardware as Actions). The summary is that markdownlint-cli 0.33.0 takes about 1 second, 0.34.0 takes about 54 seconds, and 0.34.0 with the better table code for micromark takes about 3 seconds. It's slower as expected, but only by 2 seconds, not 53 seconds. This difference should hopefully be insignificant in your Workflow scenario.

@DavidAnson ➜ /workspaces/megalinter (main) $ npm i markdownlint-cli@0.33.0
...
@DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md
...
real    0m0.923s
@DavidAnson ➜ /workspaces/megalinter (main) $ npm i markdownlint-cli@0.34.0
...
@DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md
...
real    0m54.044s
@DavidAnson ➜ /workspaces/megalinter (main) $ npm install markdownlint-micromark@0.1.3
...
@DavidAnson ➜ /workspaces/megalinter (main) $ rm -rf ./node_modules/markdownlint/node_modules/markdownlint-micromark/
@DavidAnson ➜ /workspaces/megalinter (main) $ npm ls markdownlint-micromark
dummy.package@1.0.0 /workspaces/megalinter
├─┬ markdownlint-cli@0.34.0
│ └─┬ markdownlint@0.28.2
│   └── markdownlint-micromark@0.1.3 deduped invalid: "0.1.2" from node_modules/markdownlint
└── markdownlint-micromark@0.1.3
@DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md
...
real    0m3.043s
@DavidAnson ➜ /workspaces/megalinter (main) $ 
<!-- gh-comment-id:1552318777 --> @DavidAnson commented on GitHub (May 18, 2023): I have good news! Your project's heavy use of tables causes it to run into some really, really bad performance in `micromark`'s table code. They improved that code in a recent release (which is already used by `markdownlint` in its `next` branch). If I swap in the better table code, `markdownlint` performance is much closer to what it was in the previous version. Below are some quick timings I did in a GitHub Codespace (to approximate the same hardware as Actions). The summary is that `markdownlint-cli` 0.33.0 takes about 1 second, 0.34.0 takes about 54 seconds, and 0.34.0 with the better table code for `micromark` takes about 3 seconds. It's slower as expected, but only by 2 seconds, not 53 seconds. This difference should hopefully be insignificant in your Workflow scenario. ``` @DavidAnson ➜ /workspaces/megalinter (main) $ npm i markdownlint-cli@0.33.0 ... @DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md ... real 0m0.923s @DavidAnson ➜ /workspaces/megalinter (main) $ npm i markdownlint-cli@0.34.0 ... @DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md ... real 0m54.044s @DavidAnson ➜ /workspaces/megalinter (main) $ npm install markdownlint-micromark@0.1.3 ... @DavidAnson ➜ /workspaces/megalinter (main) $ rm -rf ./node_modules/markdownlint/node_modules/markdownlint-micromark/ @DavidAnson ➜ /workspaces/megalinter (main) $ npm ls markdownlint-micromark dummy.package@1.0.0 /workspaces/megalinter ├─┬ markdownlint-cli@0.34.0 │ └─┬ markdownlint@0.28.2 │ └── markdownlint-micromark@0.1.3 deduped invalid: "0.1.2" from node_modules/markdownlint └── markdownlint-micromark@0.1.3 @DavidAnson ➜ /workspaces/megalinter (main) $ time ./node_modules/.bin/markdownlint --config ./.github/linters/.markdownlint.json --ignore node_modules **/*.md ... real 0m3.043s @DavidAnson ➜ /workspaces/megalinter (main) $ ```
Author
Owner

@nvuillam commented on GitHub (May 18, 2023):

@DavidAnson thanks for the analysis :)

Do you plan to release a next version soon ?

We are close to releasing a new major MegaLinter version and I really would like markdownlint to be performant again within it :)

<!-- gh-comment-id:1552659650 --> @nvuillam commented on GitHub (May 18, 2023): @DavidAnson thanks for the analysis :) Do you plan to release a next version soon ? We are close to releasing a new major MegaLinter version and I really would like markdownlint to be performant again within it :)
Author
Owner

@DavidAnson commented on GitHub (May 18, 2023):

I am iterating on the VS Code extension right now and I think there are three open bugs in the markdownlint repo that I would like to fix before doing a release. That's probably not going to be soon enough for you. What about not upgrading the version of markdownlint-cli for this release of MegaLinter?

<!-- gh-comment-id:1553237014 --> @DavidAnson commented on GitHub (May 18, 2023): I am iterating on the VS Code extension right now and I think there are three open bugs in the markdownlint repo that I would like to fix before doing a release. That's probably not going to be soon enough for you. What about not upgrading the version of markdownlint-cli for this release of MegaLinter?
Author
Owner

@nvuillam commented on GitHub (May 18, 2023):

@DavidAnson there was no wrong answer, I'll downgrade for now, and once you'll have released I'll upgrade again to the latest version :)

Thanks a lot for your support :)

<!-- gh-comment-id:1553270011 --> @nvuillam commented on GitHub (May 18, 2023): @DavidAnson there was no wrong answer, I'll downgrade for now, and once you'll have released I'll upgrade again to the latest version :) Thanks a lot for your support :)
Author
Owner

@DavidAnson commented on GitHub (May 18, 2023):

Great. Sorry for the trouble!

<!-- gh-comment-id:1553345803 --> @DavidAnson commented on GitHub (May 18, 2023): Great. Sorry for the trouble!
Author
Owner

@DavidAnson commented on GitHub (Jun 1, 2023):

More good news! The two commits I made to micromark to improve performance showed up in a recent build which will be part of the next markdownlint release in a few days.

https://github.com/micromark/micromark/releases/tag/3.2.0

<!-- gh-comment-id:1571300626 --> @DavidAnson commented on GitHub (Jun 1, 2023): More good news! The two commits I made to `micromark` to improve performance showed up in a recent build which will be part of the next `markdownlint` release in a few days. https://github.com/micromark/micromark/releases/tag/3.2.0
Author
Owner

@nvuillam commented on GitHub (Jun 1, 2023):

Good news indeed, I stay tuned :)

<!-- gh-comment-id:1571341657 --> @nvuillam commented on GitHub (Jun 1, 2023): Good news indeed, I stay tuned :)
Author
Owner

@DavidAnson commented on GitHub (Jun 2, 2023):

Fixed in v0.29.0.

<!-- gh-comment-id:1573104223 --> @DavidAnson commented on GitHub (Jun 2, 2023): Fixed in `v0.29.0`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2387
No description provided.