Describe the bug
When running theme watch for a project with the following ignore_files setting in config.yml (no other settings aside from essential)..
ignore_files:
- config/*
- notes/*
- node_modules/*
- ./package.json
- ./package.lock.json
- prepros*
- ./.vscode/*
- liquid-testing/*
- local-files/*
- ./README.md
- tests/*
- src/*
- webpack*.js
- ./tsconfig.json
CPU usage starts and remains at at-least 15% - remaining between here and 21% - ish. I am using a fairly fast machine - see specs below.
Is is worth noting that the total project folder size is 141MB. 128MB belongs in the node_modules folder (which is ignored), and a lot of the remaining 13MB is also ignored in the other ignored directories. This only leaves a few MB of project files left that are being watched.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A low CPU usage, as is typically reported.
Environment (please complete the following information):
Any idea what is going on here? Seems quite mad that there is such high CPU usage.
The problem still persists whether running theme watch from WSL or windows, and still persists when all editors (Including the workspace) are closed. If also still persists regardless of whether the ignore_files option is supplied in config.yml. And the ignore_files option does work when the file paths are supplied
We, there may be an issue with the ignore patterns on watch for windows currently, I should be able to have a pre-release for you today or tomorrow for you to see if it fixes the issue for you.
Nice one, thanks!
Okay try updating to the patch version with theme update --verison=v1.0.2-issue664
Just tried it running both through WSL and windows git bash. It looks like the issue is still persisting, with CPU usage starting and remaining at ~20+%
EDIT: Although running the above update command reports a successful update, running 'theme version' comes back with version 1.0.1 (on both Windows/WSL), if that signal anything..
yes that is to be expected because it is pre-release
I am having the same issue on a 2018 Macbook Pro, but perhaps worse.
In my config, I am ignoring node_modules. If I run the tree command to mimic that, I get 9 directories, 237 files as output.
Here is some system info:
OS: macOS Mojave 10.14.6 18G1012 x86_64
Host: MacBookPro15,1
Kernel: 18.7.0
CPU: Intel i7-8750H (12) @ 2.20GHz
theme watch immediately jumps to ~50% CPU and will remain there, rarely dropping under 40% usage. It turns my Mac into a space heater!
For fun, I started a 30 second timer and then looked at the # of syscalls the theme binary had made during that time frame. Activity Monitor is reporting 2,394,426.
Perhaps it is worth looking at https://github.com/fsnotify/fsnotify as a backing filesystem watcher as opposed to https://github.com/radovskyb/watcher ?
@whalesalad themekit used fsnotify in the past thank you for your research. We moved onto a polling mechanism because it could be more reliable cross-platform and less likely to hit file descriptor limits on macOS.
This performance issue is not seemingly widespread, however, and CPU usage spikes are in the minority. I often run themekit all day and it does not run over 5% cpu. There is some tuning that may need to be done because I know that the faster I loop the more CPU this uses, but the slower I poll for events the slower themekit reacts to events. It is a balance of making this work reliably for everyone, managing cpu use, and making themekit responsive.
Lastly, to clear up any misunderstandings, you do not need to ingnore your node_modules folder. Themes in shopify only have a determined set of directories so themekit only watches those. Anything outside of those is not touched. The ignore config is commonly for ignoring config files in the config directory so that they are not accidentally changed
I often run themekit all day and it does not run over 5% cpu.
Very very interesting to see such a stark difference in our experiences.
How can I help debug? Is there something I can turn on to emit more telemetry during use? I was very surprised to see OS X reporting that 2 million syscall number after only ~30 seconds of operation. That is over 66k calls per second.
Yes how many files do you have in your theme? The current poll interval is half a second. I believe the main thing it is doing is stating the file but there may be other things. I am also maintaining a list of file checksums to ensure we are not updating a file without reason but that means reading the files when needed as well. Is your theme particularly large? Do you possibly have another tool that is touching all of these files but themekit is not updating them because the checksum has not changed? Do you have another tool that is constantly running along side themekit?
To my knowledge I do not have any other processes watching this directory.
There are 273 files in the directory, ignoring node_modules, here is the output of that actually if it helps:
.
โโโ README.md
โโโ assets
โย ย โโโ 1-no-filter.4270cd8.png
โย ย โโโ 2-polaroid.111940e.png
โย ย โโโ 3-grayscale.c85c045.png
โย ย โโโ 4-sepia.35ab3f2.png
โย ย โโโ 5-vintage.a337338.png
โย ย โโโ 6-kodachrome.3918134.png
โย ย โโโ 7-technicolor.d43a0a5.png
โย ย โโโ FontAwesome.otf
โย ย โโโ MaterialIcons-Regular.012cf6a.woff
โย ย โโโ MaterialIcons-Regular.570eb83.woff2
โย ย โโโ MaterialIcons-Regular.a37b0c0.ttf
โย ย โโโ MaterialIcons-Regular.e79bfd8.eot
โย ย โโโ ajax-cart.js.liquid
โย ย โโโ app.0db9d4ec1f27923f38c45a07acc4a9df.css
โย ย โโโ app.0db9d4ec1f27923f38c45a07acc4a9df.css.map
โย ย โโโ app.109ba5f5bc11bcab4611.js
โย ย โโโ app.109ba5f5bc11bcab4611.js.map
โย ย โโโ app.333845b73793bea950a8.js
โย ย โโโ app.3a64906fecfc54eeee9b.js
โย ย โโโ app.40d57543e4a0cd2b8d70.js
โย ย โโโ app.427de103fbb5cb7e110e.js
โย ย โโโ app.44f2dc989b3a1ba3b1278d88f9a6f692.css
โย ย โโโ app.47aa6ad109b75d6e8bc4.js
โย ย โโโ app.4d9ed69528c54968598134db6172cf25.css
โย ย โโโ app.50636f0d984671600f623a65e98b4660.css
โย ย โโโ app.6e48781a740e71eceb80.js
โย ย โโโ app.840052506cce2d3239f7.js
โย ย โโโ app.864f7f3f12c6c290dd6f.js
โย ย โโโ app.864f7f3f12c6c290dd6f.js.map
โย ย โโโ app.89e2e444ce8fb4614e90.js
โย ย โโโ app.98f45721a211e37b568b.js
โย ย โโโ app.c1b448afa351022da2ea12fea7198e4d.css
โย ย โโโ app.cfc55e6e54f18e2ed412.js
โย ย โโโ app.dd69a1fe0246d53860ed.js
โย ย โโโ app.deb60afaecd662594c6cf7f665bb0c5d.css
โย ย โโโ app.deb60afaecd662594c6cf7f665bb0c5d.css.map
โย ย โโโ app.f2366f4b4ebc1f5e8e39.js
โย ย โโโ app.f4ae627f392af77fb339.js
โย ย โโโ app.f52065953c1d0d2920b590bd5289a5ca.css
โย ย โโโ app.fe5acacc81cb0a93adbb59f3d26d36de.css
โย ย โโโ circular-black.0637f8a.woff
โย ย โโโ circular-black.0a44f42.eot
โย ย โโโ circular-black.5ddff65.ttf
โย ย โโโ circular-blackitalic.67f978f.eot
โย ย โโโ circular-blackitalic.68725b4.ttf
โย ย โโโ circular-blackitalic.f3365c7.woff
โย ย โโโ circular-bold.7ebfd13.eot
โย ย โโโ circular-bold.a5811b7.woff
โย ย โโโ circular-bold.fc45c93.ttf
โย ย โโโ circular-bolditalic.21dc7c6.woff
โย ย โโโ circular-bolditalic.289de4b.ttf
โย ย โโโ circular-bolditalic.9ff8ed2.eot
โย ย โโโ circular-book.0b4d2d2.woff
โย ย โโโ circular-book.1f6e1b9.ttf
โย ย โโโ circular-book.aa42947.eot
โย ย โโโ circular-medium.12c4b42.eot
โย ย โโโ circular-medium.3900fca.ttf
โย ย โโโ circular-medium.b839115.woff
โย ย โโโ circular-mediumitalic.61ff889.woff
โย ย โโโ circular-mediumitalic.aaae873.eot
โย ย โโโ circular-mediumitalic.c423f01.ttf
โย ย โโโ close.png
โย ย โโโ custom.js.liquid
โย ย โโโ element-icons.535877f.woff
โย ย โโโ element-icons.732389d.ttf
โย ย โโโ fa-brands-400.eot
โย ย โโโ fa-brands-400.svg
โย ย โโโ fa-brands-400.ttf
โย ย โโโ fa-brands-400.woff
โย ย โโโ fa-brands-400.woff2
โย ย โโโ fa-regular-400.eot
โย ย โโโ fa-regular-400.svg
โย ย โโโ fa-regular-400.ttf
โย ย โโโ fa-regular-400.woff
โย ย โโโ fa-regular-400.woff2
โย ย โโโ fa-solid-900.eot
โย ย โโโ fa-solid-900.svg
โย ย โโโ fa-solid-900.ttf
โย ย โโโ fa-solid-900.woff
โย ย โโโ fa-solid-900.woff2
โย ย โโโ fancybox_loading.gif
โย ย โโโ fancybox_loading_2x.gif
โย ย โโโ fancybox_overlay.png
โย ย โโโ fancybox_sprite.png
โย ย โโโ fancybox_sprite_2x.png
โย ย โโโ fastclick.min.js
โย ย โโโ fontawesome-webfont.eot
โย ย โโโ fontawesome-webfont.svg
โย ย โโโ fontawesome-webfont.ttf
โย ย โโโ fontawesome-webfont.woff
โย ย โโโ fontawesome-webfont.woff2
โย ย โโโ gift-card.scss.liquid
โย ย โโโ handlebars.min.js
โย ย โโโ ico-select.svg.liquid
โย ย โโโ icons.eot
โย ย โโโ icons.json
โย ย โโโ icons.svg
โย ย โโโ icons.ttf
โย ย โโโ icons.woff
โย ย โโโ jquery-3.3.1.min.js
โย ย โโโ jquery.currencies.min.js
โย ย โโโ manifest.ccbad715795a8d4b479b.js
โย ย โโโ manifest.ccbad715795a8d4b479b.js.map
โย ย โโโ modernizr.min.js
โย ย โโโ open-iconic.3cf9783.woff
โย ย โโโ open-iconic.47151e8.eot
โย ย โโโ open-iconic.93cc7aa.ttf
โย ย โโโ password.scss.liquid
โย ย โโโ plugins.css.liquid
โย ย โโโ plugins.js
โย ย โโโ respond-proxy.html
โย ย โโโ respond.min.js
โย ย โโโ scripts.js
โย ย โโโ scripts.js.map
โย ย โโโ slider-arrows.png
โย ย โโโ soldout.png
โย ย โโโ timber.js.liquid
โย ย โโโ timber.scss.liquid
โย ย โโโ uncommon.scss.liquid
โย ย โโโ vendor-scripts.2f17f6ca4dbfcd0edb93.js
โย ย โโโ vendor-scripts.577fbfee20e7b7bcf969.js
โย ย โโโ vendor-scripts.784eafc5f39f9d667d55.js
โย ย โโโ vendor-scripts.7b85d409b9ccdd0f541a.js
โย ย โโโ vendor-scripts.8400cc1fc0147d15983a.js
โย ย โโโ vendor-scripts.e07f4f02cf3f067d2ae3.js
โย ย โโโ vendor-scripts.e07f4f02cf3f067d2ae3.js.map
โโโ config
โย ย โโโ settings_data.json
โย ย โโโ settings_schema.json
โโโ config.yml
โโโ layout
โย ย โโโ password.liquid
โย ย โโโ theme.liquid
โโโ locales
โย ย โโโ de.json
โย ย โโโ en.default.json
โย ย โโโ es.json
โย ย โโโ fr.json
โย ย โโโ pt-PT.json
โโโ package-lock.json
โโโ package.json
โโโ scripts
โย ย โโโ scripts.js
โโโ sections
โย ย โโโ announcement-bar.liquid
โย ย โโโ article-template.liquid
โย ย โโโ blog-template.liquid
โย ย โโโ cart-template.liquid
โย ย โโโ collection-list.liquid
โย ย โโโ collection-template.liquid
โย ย โโโ custom-html.liquid
โย ย โโโ feature-row.liquid
โย ย โโโ featured-blog.liquid
โย ย โโโ featured-products.liquid
โย ย โโโ footer-instagram.liquid
โย ย โโโ footer-newsletter.liquid
โย ย โโโ footer.liquid
โย ย โโโ header.liquid
โย ย โโโ home-hero.liquid
โย ย โโโ image-bar.liquid
โย ย โโโ image-with-text-overlay.liquid
โย ย โโโ indiv-product.liquid
โย ย โโโ instagram.liquid
โย ย โโโ list-collections-template.liquid
โย ย โโโ logo-bar.liquid
โย ย โโโ map.liquid
โย ย โโโ newsletter.liquid
โย ย โโโ password-template.liquid
โย ย โโโ product-template.liquid
โย ย โโโ products-block.liquid
โย ย โโโ rich-text.liquid
โย ย โโโ slideshow.liquid
โย ย โโโ testimonials.liquid
โย ย โโโ text-adverts.liquid
โย ย โโโ video.liquid
โโโ snippets
โย ย โโโ ajax-cart-template.liquid
โย ย โโโ breadcrumb.liquid
โย ย โโโ collection-sort-by.liquid
โย ย โโโ currencies.liquid
โย ย โโโ customizer_asset_paths.liquid
โย ย โโโ font-links.liquid
โย ย โโโ grid-view-item-no-match.liquid
โย ย โโโ grid-view-item.liquid
โย ย โโโ icon-amazon_payments.liquid
โย ย โโโ icon-american_express.liquid
โย ย โโโ icon-apple_pay.liquid
โย ย โโโ icon-bitcoin.liquid
โย ย โโโ icon-cirrus.liquid
โย ย โโโ icon-dankort.liquid
โย ย โโโ icon-diners_club.liquid
โย ย โโโ icon-discover.liquid
โย ย โโโ icon-dogecoin.liquid
โย ย โโโ icon-dwolla.liquid
โย ย โโโ icon-forbrugsforeningen.liquid
โย ย โโโ icon-interac.liquid
โย ย โโโ icon-jcb.liquid
โย ย โโโ icon-litecoin.liquid
โย ย โโโ icon-maestro.liquid
โย ย โโโ icon-master.liquid
โย ย โโโ icon-paypal.liquid
โย ย โโโ icon-stripe.liquid
โย ย โโโ icon-visa.liquid
โย ย โโโ live-search-result.liquid
โย ย โโโ mega-menu.liquid
โย ย โโโ mobile-search-bar.liquid
โย ย โโโ oldIE-js.liquid
โย ย โโโ pagination.liquid
โย ย โโโ popup.liquid
โย ย โโโ product-grid-item-price.liquid
โย ย โโโ product-grid-item.liquid
โย ย โโโ related-products.liquid
โย ย โโโ respond.liquid
โย ย โโโ responsive-background-image.liquid
โย ย โโโ responsive-image.liquid
โย ย โโโ search-bar.liquid
โย ย โโโ site-nav--mega-menu.liquid
โย ย โโโ site-nav.liquid
โย ย โโโ social-icons.liquid
โย ย โโโ social-meta-tags.liquid
โย ย โโโ swatch.liquid
โโโ templates
โโโ 404.liquid
โโโ article.liquid
โโโ blog.liquid
โโโ cart.liquid
โโโ collection.liquid
โโโ customers
โย ย โโโ account.liquid
โย ย โโโ activate_account.liquid
โย ย โโโ addresses.liquid
โย ย โโโ login.liquid
โย ย โโโ order.liquid
โย ย โโโ register.liquid
โย ย โโโ reset_password.liquid
โโโ gift_card.liquid
โโโ index.liquid
โโโ list-collections.liquid
โโโ page.contact.liquid
โโโ page.liquid
โโโ password.liquid
โโโ product.liquid
โโโ search.json.liquid
โโโ search.liquid
9 directories, 237 files
Can confirm on windows using WSL. All other commands are fine, but theme watch keeps my CPU at 35% and there's a large startup delay (~30 sec). I have an i5 6600k.
Rolling back to 1.0.0 worked for me. theme update --version=1.0.0
@HauntedSmores which version were you on before? Did you try v1.0.3 there were some performance tunings in 1.02? I specifically moved away from fsnotify because it was broken for windows systems. I will try updating that library as there have been a couple of releases since I added it to this project. Plus I will try to tune the polling interval to try and reduce usage as well.
edit: I have noticed the startup delay while testing on windows as well and I have no idea what it is. All of my go programs that I test on windows have a delay while starting up.
Can confirm on windows using WSL. All other commands are fine, but
theme watchkeeps my CPU at 35% and there's a large startup delay (~30 sec). I have an i5 6600k.Rolling back to
1.0.0worked for me.theme update --version=1.0.0
Wow, this fixes everything for me too. Startup time is very quick, rather than 30ish seconds, and CPU is now remaining at 1-2%; should have tried this before!
@tanema Not sure what I was at before this all happened, but I upgraded to latest which was 1.0.3 and gave me this issue. Then I just tried 1.0.0 on a whim and havnt changed since its been working for me. Also, not sure how relevant this is but, I havn't noticed any other terminal/cli tools having issues. Parcel and rollup watch commands work just fine.
Interesting, if 1.0.0 works well for you then it is not the watching backend because that was introduced in 1.0.0 so I will try to examine additions since then. Thanks for the info
I just tested this and can confirm that switching back to version 1.0.0 reduces CPU usage on OS X from 40% to 1%. 1.0.1, 1.0.2, 1.0.3 all use 40%+ CPU.
I can also confirm that 1.0.0 doesn't have slow startup or high CPU usage during watch, as opposed to 1.0.3. Windows 10 x64.
Just chiming in with similar results (macOS High Sierra 10.13.6) switching from ThemeKit v1.0.3 to v1.0.0 reduces theme watch CPU usage from a constant 40% - 50% to 0.7% - 1.0%.
Same here. With v1.0.3 it takes a long time to start on Windows 10. Also it takes way longer to process and update the same than with v1.0.0. The longer you keep theme watch open the longer it takes to upload the files. With v1.0.3 my cpu usage is way over 70% all the time. I have an i5-3570k and 16 gb ram.
I now downgraded to v1.0.0 and it works way better.
theme watch on Macbook pro (Catalina)
v1.0.3 - 60 % CPU constantly
v1.0.0 - 1 % CPU constantly
Same problem here. any idea @tanema ?
Themekit v1.0.3
MacBook Pro, Mojave 10.14.6
theme watch 100% CPU usage
Yeah, just upgraded ThemeKit and suddenly seeing 50%+ CPU usage all the time....
ThemeKit 1.1.1 darwin/amd64
MacBook Air (11-inch, Early 2015)
2.2 GHz Intel Core i7
8 GB 1600 MHz DDR3
macOS 10.14.6
The same issue here. ~ 50% CPU usage using "theme watch" command
ThemeKit 1.1.2
Macbook Pro macOS Catalina
node_modules folder is included in my root folder.
when removed, CPU usage is normal which means node_modules is the problem here.
I had to downgrade to 1.0.0 and now it's okay.
node_modules folder is included in my root folder.
when removed, CPU usage is normal which means node_modules is the problem here.
This is a pretty good insight, I will look into this. Currently the watcher just watches the root directory and filters events based on project folders. This was done because some times you will start theme watch without one of the directories and add it later, and it will not be watched by themekit. I think I can fix this.
I too am suffering from the theme watch issue on my MBP and 55%+ CPU usage
And if I remove node_modules from the project it does seem that the situation resolves itself.
okay! Give it a try theme update --version=v1.1.5-issue664 and let me know if theme watch is still killing your CPU
@tanema might be too early to say it is for sure fixed, but it does seem to me like it might be! 3.3% CPU usage now.
However it does seem like something you did may have messed with themekit's ability to find the assets dir? Got this error:
[development] error loading /Users/adriano/Documents/Projects/xxxxxxxxxxxxxxxxx/assets: readAsset: open /Users/adriano/Documents/Projects/xxxxxxxxxxxxxxxxx/Users/adriano/Documents/Projects/xxxxxxxxxxxxxxxxx/assets: no such file or directory
@adrianocr I do not get this error while running watch so I will need more information.
Hi @tanema I had the same issue with cpu usage on intel i5 Catalina and this patch --version=v1.1.5-issue664 resolved it for me. Thanks!
@tanema sorry, seemed to be related to this one project. Can't reproduce the issue any longer.
okay! Give it a try
theme update --version=v1.1.5-issue664and let me know iftheme watchis still killing your CPU
helped me a lot... 1.1.5 works much better than 1.1.4 for me (MacOS Mojave)
Thank you for this fix! It made a big difference, dropping from ~30% cpu usage down to ~1%. Running macOS Big Sur.
Most helpful comment
theme watchon Macbook pro (Catalina)v1.0.3 - 60 % CPU constantly
v1.0.0 - 1 % CPU constantly