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

slow processing of long lines #221

Closed
sfc-gh-pmardziel opened this issue Jun 13, 2024 · 2 comments · Fixed by #222
Closed

slow processing of long lines #221

sfc-gh-pmardziel opened this issue Jun 13, 2024 · 2 comments · Fixed by #222
Labels
bug Something isn't working performance

Comments

@sfc-gh-pmardziel
Copy link

sfc-gh-pmardziel commented Jun 13, 2024

When processing a file that has a long line (no line breaks), the plugin takes more time than expected. This becomes especially problematic when content is markdown that includes an embedded image whose long base64 encoding is on a single line. Here is a small example using ipsum lorem: https://gist.github.com/sfc-gh-pmardziel/15c1242a9e4e3760ba15a0d324d414da . This example takes about 50 seconds to process the computation that is indicated by this --verbose logline:

DEBUG   -  Running `page_markdown` event from plugin 'include-markdown'

Note that in this example and in base64 encodings, the default opening_tag and closing_tag are not found anywhere in the line and changing them to something that is longer/harder to match has no affect on the slowness. I thus theorize that some other aspect of the regex that is being matched is responsible for the long run time.

Environment:

> pip list | grep mkdocs
mkdocs                            1.6.0
mkdocs-autorefs                   1.0.1
mkdocs-get-deps                   0.2.0
mkdocs-include-markdown-plugin    6.2.0
mkdocs-jupyter                    0.24.7
mkdocs-material                   9.5.26
mkdocs-material-extensions        1.3.1
mkdocs-redirects                  1.2.1
mkdocstrings                      0.25.1
mkdocstrings-python               1.10.3
> python --version
Python 3.12.3
> uname -a
Darwin FVWKKW4JLF 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:17:33 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6031 arm64

This is an "Apple M1" mac in case it wasn't clear from that uname.

@mondeja
Copy link
Owner

mondeja commented Jun 13, 2024

As a workaround, with v6.2.0 you can include the image in your markdown file using recursive=false and the regex will not be applied to that long line.

@mondeja mondeja added the bug Something isn't working label Jun 21, 2024
@mondeja
Copy link
Owner

mondeja commented Jun 21, 2024

Fixed on v6.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants