question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abnormally high resource usage and slow builds

See original GitHub issue

I’m noticing high CPU and RAM usage when building using version >0.5.3.

I’ve tested most versions from 0.5.1-0.5.8 (latest) and 0.5.2/0.5.3 seem to be the fastest, with version 0.5.1 being a close second.

Each time after I get the last “Image at xxx optimized in yyyms”, I get a “Completed in xx.” and then the CPU spikes. No transformed images are written to the build dir at that point, This last “step” takes much more time than the rest of the build when in finishes. Emphasis on when because I’ve had to forcibly terminate the build a couple of times. Using versions above 0.5.5 (I think) dramatically worsens the effect.

On the latest version, this last “step” pushes my CPU to 100% and I’ve noticed it take as much as 9.5GB of RAM. (For reference I have a desktop computer with a 6 core/12 thread i7 8700K and 16GBs of RAM). Initially I thought it was an issue with Windows so I rebooted to my Linux install and tried it there… It crashed my desktop environment and I got kicked back to the login screen.

Something of note, later versions also throw an error only on Windows when building basically anything else apart from avif files. I don’t know if these are caused by the same issue (earlier versions are ok).

I’d also like to note what I’m trying to do: I am working on a blog website that uses wordpress as a CMS. I’m currently only using the Picture component passing the src attribute as a URL. The blog currently has <50 images.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
skourismanoliscommented, Apr 25, 2022

I created this repo to explore and demonstrate the issue astro-imagetools-example. It’s using the astro blog starter, with modifications in src/pages/index.astro. I’m basically fetching a bunch of images from the blog I’m working on and displaying them. I tried to simply display a single image from imgur multiple times but the build worked perfectly.

However with experimentation I’ve found the following:

  • High resource usage still happens on 0.5.3, although it’s not as bad as on 0.5.8. Builds actually finish
  • Once a build finishes in 0.5.3, subsequent builds are very fast and the same effect is not observed. I suppose you’re implementing some sort of cache.
  • The problem seems to appear (or worsen) when having images with a large total size. This example fetches 64 images but by using Array.slice() I managed to reproduce the problem on much smaller counts of images.
  • On windows, build fails on >=0.5.4 with Input file is missing error.
  • I used gitpod to make this example, on 0.5.3 - 0.5.6 the first build finishes on ~160s while subsequent builds finish in ~5s. On 0.5.7 and 0.5.8 it never finishes. Here’s a gitpod snapshot.

I changed versions on gitpod with:

rm -rf node_modules
yarn add astro-imagetools@version
yarn build

While on my windows pc I just removed node_modules/.cache since deleting and reinstalling the whole node_modules folder took a lot of time.

1reaction
RafidMuhymincommented, May 21, 2022

@skourismanolis a fix for the regression has been merged and released in 0.6.9.

After upgrading to astro-imagetools@0.6.9 and running the same tests on GitPod:

  • jpg- it took 9s to generate jpg images for all the 240 images
  • png- it took 13s to generate png images for all the 240 images
  • webp- it took 20s to generate webp images for all the 240 images
  • avif- it took 204s to generate jpg images for all the 240 images

Now, https://github.com/skourismanolis/astro-imagetools-example builds successfully on the latest release. It’s taking 225s for a build to finish on GitPod.

Note: The increase in build time in 0.6.9 from 0.5.3 is not due to another regression. It’s because the maximum default number of breakpoints was 3 in v0.5.3 and it’s 11 since v0.5.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix High CPU Processor Usage
Why is my PC using maximum CPU resources? Learn why, and how to fix high CPU loads on your computer.
Read more >
What to do When Your High-End Computer is Running Slow
Too many startup programs are one of the most common things to cause slow boot times and the poor running speed of the...
Read more >
How to Fix High CPU Usage for Windows
The symptoms of high CPU usage are familiar: the cursor moves jerkily and slowly, and applications begin to lag or shut down.
Read more >
How to Fix High CPU Usage
Find out all the reasons why your PC displays high CPU usage. Our step-by-step guide will show you how to fix your CPU...
Read more >
What is CPU usage, and how to fix high CPU usage
If your PC has slowed down, high CPU usage may be the cause. In this guide, we will show you how to check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found