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

pagination.pagerSize has bad performance #13078

Open
sgraband opened this issue Nov 21, 2024 · 7 comments
Open

pagination.pagerSize has bad performance #13078

sgraband opened this issue Nov 21, 2024 · 7 comments

Comments

@sgraband
Copy link

I updated the hugo version for our website to 0.139.0 lately. The build now gives this warning:

WARN deprecated: site config key paginate was deprecated in Hugo v0.128.0 and will be removed in a future release. Use pagination.pagerSize instead.

Therfore i changed the entry in the config.toml from

paginate = "6"

to

[pagination]
pagerSize = "6"

While this works it increases the build time of the website by a factor of 10 (from 1 minute to 10 minutes).
Is there a reason why the build time increases that drastically? Or is there a better way to remove the deprecated field and still have the normal performance?

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.139.0-dacef0df92a9a20072b4eaa42003e1a63ace8f41+extended linux/amd64 BuildDate=2024-11-18T16:17:45Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

yes

@bep
Copy link
Member

bep commented Nov 21, 2024

While this works it increases the build time of the website by a factor of 10 (from 1 minute to 10 minutes).

This doesn't make sense that moving a config option should slow down the build, so there must be something else in play, which is impossible to tell without seeing the site source.

@jmooring
Copy link
Member

This doesn't make sense

Agreed. Just tested with a 10,000 page size. No difference.

@sgraband
Copy link
Author

Thank you for the fast response!
Yes it is indeed strange, however i retested it once again. I build the site with paginate and it takes 70586 ms. Then i clean the repository and rebuild it with pagination.pagerSize and the build takes 747651 ms.

I actually spotted an additional oddity, which might give some insight into what happens. The number of paginator pages actually increases from 448 to 71680, which explains the longer build time, but i do not understand where the additional pages come from.

Our usage of the paginator is basically this code here:

      {{ $p := where site.AllPages "Section" "in" site.Params.mainSections }}
      {{ $paginator := .Paginate (where $p "Title" "!=" "EclipseSource Blogs") }}
      {{ range $paginator.Pages }}

Any ideas or pointers on where this could come from?

@bep
Copy link
Member

bep commented Nov 22, 2024

[pagination]
pagerSize = "6"

Can you try to remove the quotes and make it:

[pagination]
pagerSize = 6

(a related tip would be to do hugo config and see the effective configuration).

How many pages in total are there in the list passed to .Paginate?

@sgraband
Copy link
Author

This seems to make no difference (build time stays the same and hugo config output is identical).

There are 1345 pages in that list. Which should make 224 paginations.

With paginate we get a factor 2 of this for the english version and the correct amount for the german page:

                   |  EN  | DE   
-------------------+------+------
  Pages            | 1460 |  63  
  Paginator pages  |  448 | 224  
  Non-page files   | 3010 |   0  
  Static files     |   28 |  28  
  Processed images | 6018 |   0  
  Aliases          | 1501 | 203  
  Cleaned          |    0 |   0 

With pagination.pagerSize we get a factor 320 for the english pages and a factor 4 for the german pages:

                   |  EN   | DE   
-------------------+-------+------
  Pages            |  2095 |  69  
  Paginator pages  | 71680 | 896  
  Non-page files   |  3010 |   0  
  Static files     |    28 |  28  
  Processed images |  6018 |   0  
  Aliases          |  1819 | 206  
  Cleaned          |     0 |   0 

The state with paginate might be correct, due to aliases, but i would need to check that.

In the config i saw, that the pagination.path is set to 'page'. I did not really get what this does from the documentation, could this have something to do with it?

@bep
Copy link
Member

bep commented Nov 22, 2024

@sgraband if you can somehow give me access to the Hugo source for this site, I can probably figure it out, but I can not guess by the numbers you're showing.

@jmooring
Copy link
Member

jmooring commented Nov 22, 2024

This may be unrelated to the problem you are experiencing, but I am curious.

Why are you using site.AllPages instead of site.Pages or site.RegularPages? The former returns all pages for all languages.

Consider this site configuration:

disableKinds = ['rss','sitemap','taxonomy','term']

If your EN site has 100 pages, and your DE site has 42 pages:

  • site.AllPages.Len returns 146 for both the EN site and the DE site
  • site.Pages.Len returns 102 for the EN site and 44 for the DE site
  • site.RegularPages.Len returns 100 for the EN site and 42 for the DE site

Your page collection may be correct, but it did catch my attention...

@jmooring jmooring changed the title pagniation.pagerSize has bad performance pagination.pagerSize has bad performance Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants