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

Improve partial rebuilds #11543

Closed
bep opened this issue Oct 8, 2023 · 2 comments
Closed

Improve partial rebuilds #11543

bep opened this issue Oct 8, 2023 · 2 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Oct 8, 2023

There are some problems with how we currently do partial rebuilds:

  • In some situations it's too coarse grained (when in doubt, build everything)
  • In some situations we don't detect the complete change set, and you end up having to do a server restart.

For the first item we have a "fast render mode", which helps. Most of the issues in the second item can be worked around with "cache buster" configuration, but it's hard to get right.

The goal for the next Hugo version is, for a given change when running the server, to quickly

  1. Detect all other resources that is likely to change because of this and clear any related cache/state to allow them to be rebuilt.
  2. Have as few false negatives as possible. These should be documented so they could be worked around.

Some examples:

  • Edit of layouts/_default/single.html should re-render items1 using this template2.
  • Edit of layouts/_default/baseof.html etc. should work as expected.
  • Edit of layouts/partials/foo.html should re-render items using this template2.
  • Edit of a template used in rendering of page content (e.g. .Content) should re-render that content2, e.g. render hook and shortcode templates.
  • Edit of a given content file (front matter or Markdown) should re-render items using this content.
  • Transitive changes to content or other resources should be detected, e.g. page1 -> shortcode -> partial -> page2.Title.
  • The transformations for a resource (e.g. {{ $css | fingerprint }}) will be rebuilt if the source changes.
  • Edit of a transitive dependency in JavaScript (imports resolved with js.Build) should work.
  • Edit of a transitive dependency in CSS when enabling inlineImports in resources.PostCSS should work.
  • Edit of a transitive dependency in CSS for Dart Sass should work.
  • Edit of a transitive dependency in CSS for LibSass should work.
  • Changes to aggregated data (e.g. site.Lastmod) should work.
  • Changes to cascade should work.
  • Changes should be reflected in all collections, e.g. site.RegularPages, $page.Pages.

Some special considerations:

It would still be recommended to design the site to produce the least amount of changes during development. A typical construct would be to avoid fingerprinting in development:

{{ $js := resources.Get "js/main.js" | js.Build }}
{{ if not hugo.IsDevelopment }}
    {{ $js = $js | fingerprint }}
{{ end }}

The above JS file would typically be included via its RelPermalink into many (maybe all) of the rendered HTML files, and we really don't want to re-render everything on every change of a JS file. So we special case the use of RelPermalink and Permalink, unless these get updated on change (e.g. fingerprint).

I have a working version of the above which I'm in the process of wrapping up, but thought I'd write it up as a proposal to potentially get some feedback.

Footnotes

  1. Typically all matching page output formats.

  2. Either directly or transitively, e.g. a partial used in a shortcode template. 2 3

@bep bep added the Proposal label Oct 8, 2023
@bep bep self-assigned this Oct 8, 2023
@bep bep added this to the v0.120.0 milestone Oct 8, 2023
@bep bep pinned this issue Oct 8, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep unpinned this issue Nov 11, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@jmooring
Copy link
Member

I think that this can be closed, addressed with v0.122.0.

@bep bep closed this as completed Jan 30, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants