Skip to content

Conversation

@lenderom
Copy link
Member

@lenderom lenderom commented May 8, 2025

Description

Improve the build performance by using partial caches

Checklist

  • Check the License of new pictures (non-commercial use without attribution)

The content was modified in the following languages:

  • English
  • German

@netlify
Copy link

netlify bot commented May 8, 2025

Deploy Preview for fipguide ready!

Name Link
🔨 Latest commit 351aa97
🔍 Latest deploy log https://app.netlify.com/sites/fipguide/deploys/681ddc402b04780008e4ec9d
😎 Deploy Preview https://deploy-preview-130--fipguide.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lenderom
Copy link
Member Author

lenderom commented May 8, 2025

The most significant improvement would be, if we achieve to do the image processing only once per image. However we can't use partialCached for this, because this is still done once per language. So each image is processing twice at the moment, even if it's the same image (we don't have different images for different languages). Maybe @MoritzWeber0 has an idea?

@MoritzWeber0
Copy link
Member

MoritzWeber0 commented May 8, 2025

The most significant improvement would be, if we achieve to do the image processing only once per image. However we can't use partialCached for this, because this is still done once per language. So each image is processing twice at the moment, even if it's the same image (we don't have different images for different languages). Maybe @MoritzWeber0 has an idea?

The image processing is automatically cached and only done once - prove me wrong. The detail lies in the sentence of the last paragraph:

Hugo caches processed images in the resources directory.

When I have a look at the resources directory, I only see general images and images in the "en" directory. There is no additional "de" directory, so I'd assume that these images are no rerendered.
image

Also, the images are already fetched from the en subpath when loading german pages:
image

@lenderom
Copy link
Member Author

lenderom commented May 8, 2025

No I mean during the build process.

When running hugo server --ignoreCache --templateMetrics --templateMetricsHints you can see how often the partial image.html is called and how often it is cached.

Every Country Flag (4)
And every News Article (3)
And the Startpage image (1)

And all of this for each language.

@MoritzWeber0
Copy link
Member

MoritzWeber0 commented May 8, 2025

No I mean during the build process.

When running hugo server --ignoreCache --templateMetrics --templateMetricsHints you can see how often the partial image.html is called and how often it is cached.

Every Country Flag (4)
And every News Article (3)
And the Startpage image (1)

And all of this for each language.

That makes sense. The partial is called for each language. The question is: Is the image processing inside the partial cached?

So if I call the same image partial twice, it might resize the images the first time and the second time the expensive resizing step might be skipped and it's faster.

I have to look at this again sometime.

(In the worst case we can do the processing on our own and then ship the images via the static dir)

lenderom added 6 commits May 9, 2025 12:21
Signed-off-by: lennartrommeiss <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
Signed-off-by: lennartrommeiss <[email protected]>
@lenderom
Copy link
Member Author

lenderom commented May 9, 2025

Resizing is nativly only done once by hugo.
But we are using runner caches for the resource section for hugo now, which make a huge impacht in build speed:

Before:
image

After:
image

@lenderom lenderom marked this pull request as ready for review May 9, 2025 10:46
@lenderom lenderom merged commit cc3fa85 into main May 9, 2025
7 checks passed
@lenderom lenderom deleted the fix/performance-improvements branch May 9, 2025 10:46
@MoritzWeber0 MoritzWeber0 added the technical Technical issues, e.g. related to Hugo, HTML, CSS, deployment, etc. label May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

technical Technical issues, e.g. related to Hugo, HTML, CSS, deployment, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants