Skip to content

feat(tiles): add hot metadata cache for warm zoom >= 9 hits#218

Merged
stef-k merged 4 commits intomainfrom
feature/217-tile-metadata-hot-cache
Apr 13, 2026
Merged

feat(tiles): add hot metadata cache for warm zoom >= 9 hits#218
stef-k merged 4 commits intomainfrom
feature/217-tile-metadata-hot-cache

Conversation

@stef-k
Copy link
Copy Markdown
Owner

@stef-k stef-k commented Apr 13, 2026

Summary

  • add an in-process tile metadata hot cache for zoom >= 9 warm hits using IMemoryCache
  • add the TileMetadataHotCacheSizeMB admin setting, migration, and live MB-to-entry hint in Admin Settings
  • invalidate hot metadata entries on purge/eviction/delete paths and preserve throttled LastAccessed updates
  • add focused tests covering warm-hit seeding/bypass, revalidation refresh, fetch population, purge/eviction invalidation, and admin validation

Test Plan

  • dotnet build
  • dotnet test tests\\Wayfarer.Tests\\Wayfarer.Tests.csproj --filter "FullyQualifiedName~Wayfarer.Tests.Services.TileCacheServiceTests"
  • dotnet test tests\\Wayfarer.Tests\\Wayfarer.Tests.csproj --no-build --filter "FullyQualifiedName~Wayfarer.Tests.Controllers.AdminSettingsControllerTests|FullyQualifiedName~Wayfarer.Tests.Controllers.TilesControllerTests"

Closes #217

@stef-k
Copy link
Copy Markdown
Owner Author

stef-k commented Apr 13, 2026

Addressed the review findings around hot-hit LastAccessed throttling.

Changes in c5a21e4:

  • replaced the non-atomic touch-marker TryGetValue + Set flow with an atomic per-tile claim in TileMetadataHotCache
  • only start the 5-minute cooldown after a successful DB persist
  • abort and release the claim on missing-row / failure paths so later requests can retry immediately
  • added regression tests covering atomic claim behavior and abort-to-retry recovery

Re-verified with:

  • dotnet build
  • dotnet test tests\\Wayfarer.Tests\\Wayfarer.Tests.csproj --no-build --filter "FullyQualifiedName~Wayfarer.Tests.Services.TileCacheServiceTests|FullyQualifiedName~Wayfarer.Tests.Controllers.AdminSettingsControllerTests|FullyQualifiedName~Wayfarer.Tests.Controllers.TilesControllerTests"

@stef-k
Copy link
Copy Markdown
Owner Author

stef-k commented Apr 13, 2026

Reviewed current PR head 4d5c1e7 after the hot-hit throttling fix.

Assessment:

  • no findings on the current implementation
  • warm zoom >= 9 hits now avoid the DB metadata read while expired/miss paths continue through the existing revalidation/fetch pipeline
  • request-level tile limiting and outbound upstream limiting remain unchanged, so existing OSM-facing protections are still respected
  • admin setting validation/UI are aligned with the intended -1 or 16..512 MB behavior

Also added the 1.2.28 changelog entry to prepare the release.

@stef-k stef-k merged commit 0189ffe into main Apr 13, 2026
1 check passed
@stef-k stef-k deleted the feature/217-tile-metadata-hot-cache branch April 13, 2026 20:11
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.

Investigate warm tile cache hit latency at zoom >= 9 due to per-hit metadata DB lookups

1 participant