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

Build time significantly increases with overrides/.icons #1942

Closed
2 of 4 tasks
kcgthb opened this issue Sep 22, 2020 · 11 comments
Closed
2 of 4 tasks

Build time significantly increases with overrides/.icons #1942

kcgthb opened this issue Sep 22, 2020 · 11 comments

Comments

@kcgthb
Copy link
Contributor

kcgthb commented Sep 22, 2020

I checked that...

  • ... the documentation does not mention anything about my problem
  • ... the problem doesn't occur with the default MkDocs template
  • ... the problem is not in any of my customizations (CSS, JS, template)
  • ... there are no open or closed issues that are related to my problem

Description

The site build time significantly increases (x8) when additional icons are enabled via overrides/.icons.

Expected behavior

Same, or at least comparable build times with or without additional icons.

Actual behavior

  • without additional icons:
    $ grep -A3 pymdownx.emoji mkdocs.yml
      - pymdownx.emoji:
          emoji_index: !!python/name:materialx.emoji.twemoji
          emoji_generator: !!python/name:pymdownx.emoji.to_svg
          #    options:
          #  custom_icons:
          #    - overrides/.icons
    $ time mkdocs -q build
    
    real    0m8.947s
    user    0m8.744s
    sys     0m0.645s
    
  • with additional icons:
    $ grep -A3 pymdownx.emoji mkdocs.yml
      - pymdownx.emoji:
          emoji_index: !!python/name:materialx.emoji.twemoji
          emoji_generator: !!python/name:pymdownx.emoji.to_svg
          options:
            custom_icons:
              - overrides/.icons
    $ time mkdocs -q build
    
    real    0m57.974s
    user    0m50.919s
    sys     0m7.643s
    

The actual icons don't seem to matter, nor the number of icons in overrides/.icons.

The issue doesn't seem to be specific to Material for MkDocs, but I couldn't find any reference to custom_icons in the PyMdown Extensions documentation so I'm not exactly sure where to report this.

What seems to be happening is that with custom_icons enabled, mkdocs spends more and more time to read each page, as it's progressing through them. In verbose mode you can see that each of the lines:

DEBUG   -  Reading: docs/page.md

takes longer to process than the previous one, and end up almost crawling to a halt.
Without custom_icons, the build process goes through all of then quickly, each page taking the same time to read.

Steps to reproduce the bug

  1. enable custom icons in mkdocs.yml as per the documentation
  2. build the pages with mdocs build or mkdocs serve

Package versions

  • Python: Python 3.7.8
  • MkDocs: mkdocs, version 1.1.2
  • Material: Version: 5.5.12

Project configuration

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:pymdownx.emoji.to_svg
      options:
        custom_icons:
          - overrides/.icons
@squidfunk
Copy link
Owner

What happens when you set the emoji_generator to materialx?

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg # <-
      options:
        custom_icons:
          - overrides/.icons

@squidfunk
Copy link
Owner

Furthermore, have you tried reproducing the problem with a mint installation, only configuring icons for overrides?

@kcgthb
Copy link
Contributor Author

kcgthb commented Sep 22, 2020

What happens when you set the emoji_generator to materialx?

Same thing, apparently: reading .md pages is incrementally longer over the build process, and it ended up taking the same ~57s.

Interestingly, it's just the Reading phase that is longer, Building pages is still as quick as without custom_icons.

Furthermore, have you tried reproducing the problem with a mint installation, only configuring icons for overrides?

I just tried adding the Bootstrap icons to a straight git clone of Material for MkDocs (exactly like in the example at https://squidfunk.github.io/mkdocs-material/setup/changing-the-logo-and-icons/#additional-icons): I cloned the https://github.com/squidfunk/mkdocs-material.git repo, created the overrides/.icons directory and added the Boostrap icons in it, then enabling custom icons with:

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
      options:
        custom_icons:
          - overrides/.icons

and the build time went from 5.7s to 32.3s

@squidfunk
Copy link
Owner

Thanks so far. Does it also happen with the default or readthedocs theme?

@kcgthb
Copy link
Contributor Author

kcgthb commented Sep 22, 2020

Yes, it seems to be happening with both the default mkdocs and readthedocs themes too.

I realize it may not be specific to Material for MkDocs, but I'm not sure any other theme uses custom_icons so I wasn't too sure where to report this. Thanks!

@squidfunk
Copy link
Owner

squidfunk commented Sep 22, 2020

It's either specific to Material for MkDocs Extensions then, or MkDocs itself. @facelessuser, any idea?

@facelessuser
Copy link
Contributor

What version of that is being used? Pretty sure I fixed that: facelessuser/mkdocs-material-extensions#10. But maybe not 🤷‍♂️ .

@facelessuser
Copy link
Contributor

I think what I addressed was index getting bigger on every reload. I'm not aware of it getting bigger per page, but maybe...I'd have to take a look.

@squidfunk
Copy link
Owner

Thanks, @facelessuser! As this issue is not directly related to this project, I'm closing it. @kcgthb thanks for your thorough investigations!

@facelessuser
Copy link
Contributor

If a solution is desired, please create a bug over at the repository and provide what version you are using. Assuming I can pin it down to something I'm doing, I can fix it.

@kcgthb
Copy link
Contributor Author

kcgthb commented Sep 22, 2020

Thank you both! I created facelessuser/mkdocs-material-extensions#14

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

3 participants