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

High CPU Load #2092

Closed
petrmachcz opened this issue May 5, 2020 · 9 comments · Fixed by #2094
Closed

High CPU Load #2092

petrmachcz opened this issue May 5, 2020 · 9 comments · Fixed by #2094

Comments

@petrmachcz
Copy link

A have High CPU Load (> 20 %) with MkDocs + Material on Lenovo T460s (i5-6200U, 20 GB Ram). Notebook is hot, fan is humming and battery discharges quickly.

High load occurs during mkdocs serve. If I use mkdocs serve --no-livereload, load is OK.

High load happens even with minimal content.

SITE-TEST:

    docs:
        index.md
    mkdoc.yml

index.md:

# Hello World

mkdoc.yml

site_name: Test
theme:
    name: material
    language: cs

Load is normal, if I remove theme material.

My enviroment:

C:\Users\petrm>python --version
Python 3.8.2
C:\Users\petrm>python -m pip show mkdocs
Name: mkdocs
Version: 1.1
Summary: Project documentation with Markdown.
Home-page: https://www.mkdocs.org
Author: Tom Christie
Author-email: tom@tomchristie.com
License: BSD
Location: c:\users\petrm\appdata\roaming\python\python38\site-packages
Requires: PyYAML, livereload, lunr, Markdown, click, tornado, Jinja2
Required-by: mkdocs-material
C:\Users\petrm>python -m pip show mkdocs-material
Name: mkdocs-material
Version: 5.1.4
Summary: A Material Design theme for MkDocs
Home-page: https://squidfunk.github.io/mkdocs-material/
Author: Martin Donath
Author-email: martin.donath@squidfunk.com
License: MIT
Location: c:\users\petrm\appdata\roaming\python\python38\site-packages
Requires: pymdown-extensions, mkdocs, Pygments, mkdocs-material-extensions, markdown
Required-by: mkdocs-material-extensions
C:\Users\petrm>systeminfo

Host Name:                 T460S-WIN
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.18362 N/A Build 18362
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          Uživatel systému Windows
Registered Organization:
Product ID:                00342-50620-20329-AAOEM
Original Install Date:     29.10.2019, 23:22:13
System Boot Time:          22.04.2020, 12:13:28
System Manufacturer:       LENOVO
System Model:              20FAS47X00
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 78 Stepping 3 GenuineIntel ~2300 Mhz
BIOS Version:              LENOVO N1CET45W (1.13 ), 02.06.2016
Windows Directory:         C:\WINDOWS
System Directory:          C:\WINDOWS\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             cs;Čeština
Input Locale:              cs;Čeština
Time Zone:                 (UTC+01:00) Praha, Bratislava, Budapešť, Bělehrad, Lublaň
Total Physical Memory:     19 907 MB
Available Physical Memory: 14 060 MB
Virtual Memory: Max Size:  22 851 MB
Virtual Memory: Available: 16 008 MB
Virtual Memory: In Use:    6 843 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              \\T460S-WIN
@squidfunk
Copy link
Sponsor Contributor

squidfunk commented May 5, 2020

Related to #2061, first discussed in squidfunk/mkdocs-material#1672

@waylan
Copy link
Member

waylan commented May 5, 2020

If I use mkdocs serve --no-livereload, load is OK.

Load is normal, if I remove theme material.

Those are the two factors. The material theme has a lot of files, and watching a lot of files puts extra strain on the system. Especially if the system doesn't have an API for watching files. While Windows does have an API, my understanding is that it is less performant than Linux and Mac and you should expect more strain.

Overall, there is not much we can do. We only provide a light wrapper around lepture/python-livereload. Any performance issues with the watcher should be addressed there. The theme could reduce the number of files, but then you would loose the features it offers (besides that would be something to discuss with the Material devs, not here). That only leaves #2061 as something we can do. Therefore, I am closing this as a duplicate.

@squidfunk
Copy link
Sponsor Contributor

Wouldn't it solve the problem if we exclude theme files from mkdocs serve?

@waylan
Copy link
Member

waylan commented May 5, 2020

Wouldn't it solve the problem if we exclude theme files from mkdocs serve?

That is certainly an option. However, when I'm working on a theme (editing templates or CSS) I want to have the theme files watched. Of course, I'm only ever working on smaller themes with only a few files, so it's a non-issue for me.

Perhaps the default should be to not watch theme files. Then we could add an option to include theme files for those occasions were it is desired.

@squidfunk
Copy link
Sponsor Contributor

squidfunk commented May 5, 2020

That sounds like a great idea. I think for most of authors, watching theme files isn’t necessary. So I guess this could be implemented as an enhancement?

waylan added a commit to waylan/mkdocs that referenced this issue May 5, 2020
Add a --watch-theme option which theme devs can enable if needed.
Most users never modify the theme files and watchers are resource hogs.
Fixes mkdocs#2092.
waylan added a commit to waylan/mkdocs that referenced this issue May 5, 2020
Add a --watch-theme option which theme devs can enable if needed.
Most users never modify the theme files and watchers are resource hogs.
Fixes mkdocs#2092.
@waylan
Copy link
Member

waylan commented May 5, 2020

Actually, I'm going to classify this as a performance improvement and include it in the next buggies release. See #2094.

@petrmachcz
Copy link
Author

Thanks you.

waylan added a commit to waylan/mkdocs that referenced this issue May 7, 2020
Add a --watch-theme option which theme devs can enable if needed.
Most users never modify the theme files and watchers are resource hogs.
Fixes mkdocs#2092.
@dato
Copy link

dato commented Jul 8, 2020

I hope #2094 can be merged and released soon. Patching it locally solves the problem for me.

Some data: I tend to leave my mkdocs serve processes permanently running in a systemd --user unit, because there are three websites I modify several times per week. With the patch, after 19hs up, CPU time without having edited the site is 12 minutes. Previous instance without the patch takes 155 minutes CPU time, in the same period (without having edited the site either).

Many thanks for diagnosing and proposing a fix. Being able to patch it locally is already a great relief.


(FWIW I must also note that 12 minutes/day is still one an order of magnitud above what jekyll serve [from which I am migrating] consumes [roughly 1min/day when idle, for the same sites].)

waylan added a commit to waylan/mkdocs that referenced this issue Nov 3, 2020
Add a --watch-theme option which theme devs can enable if needed.
Most users never modify the theme files and watchers are resource hogs.
Fixes mkdocs#2092.
waylan added a commit that referenced this issue Nov 3, 2020
Add a --watch-theme option which theme devs can enable if needed.
Most users never modify the theme files and watchers are resource hogs.
Fixes #2092.
@waylan
Copy link
Member

waylan commented May 10, 2021

FYI, for anyone who has experienced performance issues with the server. We are looking at replacing the server with a different implementation which should address the concerns raised here. See #2385 for details and feel free to test and provide feedback there.

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

Successfully merging a pull request may close this issue.

4 participants