Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing \\\``… takes quadratic time #733

Closed
andersk opened this issue Nov 20, 2020 · 1 comment
Closed

Parsing \\\``… takes quadratic time #733

andersk opened this issue Nov 20, 2020 · 1 comment

Comments

@andersk
Copy link

andersk commented Nov 20, 2020

$ time node -e 'require("markdown-it")().render("\\``".repeat(10000))'
1.02user 0.00system 0:01.02elapsed 100%CPU (0avgtext+0avgdata 37880maxresident)k
0inputs+0outputs (0major+3574minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("\\``".repeat(20000))'
3.45user 0.00system 0:03.46elapsed 100%CPU (0avgtext+0avgdata 39364maxresident)k
0inputs+0outputs (0major+3679minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("\\``".repeat(40000))'
12.51user 0.01system 0:12.53elapsed 99%CPU (0avgtext+0avgdata 43220maxresident)k
0inputs+0outputs (0major+4900minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("\\``".repeat(80000))'
52.40user 0.02system 0:52.47elapsed 99%CPU (0avgtext+0avgdata 47756maxresident)k
0inputs+0outputs (0major+6870minor)pagefaults 0swaps

See also mity/md4c#59, pulldown-cmark/pulldown-cmark#247.

rlidwka added a commit that referenced this issue Nov 20, 2020
This commit adds a cache `StateInline->backticks` which remembers
positions for every possible backtick closer (`, ``, ```, etc.).

Algorithm is similar to one described here:
mity/md4c@685b714

close #733
@rlidwka
Copy link
Member

rlidwka commented Nov 20, 2020

Fixed with a cache very similar to one in cmark and md4c. Thanks for reporting.

rlidwka added a commit that referenced this issue Nov 20, 2020
This commit adds a cache `StateInline->backticks` which remembers
positions for every possible backtick closer (`, ``, ```, etc.).

Algorithm is similar to one described here:
mity/md4c@685b714

close #733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants