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

Re-introduce the LRU-evicted identities in change set calculation #13331

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ func (h *HugoSites) resolveAndClearStateForIdentities(
cachebuster func(s string) bool, changes []identity.Identity,
) error {
// Drain the cache eviction stack to start fresh.
h.Deps.MemCache.DrainEvictedIdentities()
evictedStart := h.Deps.MemCache.DrainEvictedIdentities()

h.Log.Debug().Log(logg.StringFunc(
func() string {
Expand Down Expand Up @@ -1200,6 +1200,27 @@ func (h *HugoSites) resolveAndClearStateForIdentities(
for _, c := range evicted {
changes = append(changes, c.Identity)
}

if len(evictedStart) > 0 {
// In low memory situations and/or very big sites, there can be a lot of unrelated evicted items,
// but there's a chance that some of them are related to the changes we are about to process,
// so check.
depsFinder := identity.NewFinder(identity.FinderConfig{})
var addends []identity.Identity
for _, ev := range evictedStart {
for _, id := range changes {
if cachebuster != nil && cachebuster(ev.Key.(string)) {
addends = append(addends, ev.Identity)
break
}
if r := depsFinder.Contains(id, ev.Identity, -1); r > 0 {
addends = append(addends, ev.Identity)
break
}
}
}
changes = append(changes, addends...)
}
} else {
// Mass eviction, we might as well invalidate everything.
changes = []identity.Identity{identity.GenghisKhan}
Expand Down