Skip to content

Update cache file access time on cache hit so eviction keeps the most… - #104

Closed
ryanhaguematomo wants to merge 3 commits into
6.x-devfrom
task/id-373
Closed

ryanhaguematomo wants to merge 3 commits into
6.x-devfrom
task/id-373

Conversation

@ryanhaguematomo

@ryanhaguematomo ryanhaguematomo commented Nov 11, 2026 •

Copy link
Copy Markdown

Draft state:

#84 seemingly attempted to resolve the same issue but was closed with merge. I cant find documentation as to why this was done, chasing it now to avoid any learned issues.

Description to be updated prior to making ready

This PR

deleteLeastAccessedFiles() evicts by fileatime(), but a cache hit never updated it (opcache, noatime/relatime mounts), so eviction effectively dropped the oldest written entries. Cache hits now move the access time, at most once per day per file to keep tracking writes low.

WarmDeviceDetectorCacheTest asserted the inverse behaviour and was flaky because entries written within the same second tied on fileatime(). The test now ages the entries first and asserts the most used entry is kept.

Description

Test Cause Failed jobs / month
WarmDeviceDetectorCacheTest Cache eviction uses fileatime(), and a cache hit doesn't update it 8

This PR aims to resolve the flaky test.

Checklist

  • [✔/✖/NA] Tested locally or on demo2/demo3?
  • [✔/✖/NA] New test case added/updated?
  • [✔/✖/NA] Are all newly added texts included via translation?
  • [✔/✖/NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔/✖/NA] Version bumped?
  • [✔/✖/NA] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [✔/✖/NA] Documentation updated?

ryanhaguematomo and others added 3 commits November 11, 2026 12:51
… used entries

deleteLeastAccessedFiles() evicts by fileatime(), but a cache hit never updated it
(opcache, noatime/relatime mounts), so eviction effectively dropped the oldest
written entries. Cache hits now move the access time, at most once per day per file
to keep tracking writes low.

WarmDeviceDetectorCacheTest asserted the inverse behaviour and was flaky because
entries written within the same second tied on fileatime(). The test now ages the
entries first and asserts the most used entry is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ate directly

touch() with explicit times requires owning the file, so the tracker could not update
the access time when the warm command runs as another user. touch() without times only
needs write permission.

The access time tests now call markAsAccessed() directly, since reading the file in
getCached() lets relatime mounts update the access time on their own and hide a
regression. The README documents the eviction behaviour and the required permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ryanhaguematomo
ryanhaguematomo deleted the task/id-373 branch November 12, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant