Skip to content

Conversation

conradludgate
Copy link
Contributor

@conradludgate conradludgate commented Jul 23, 2025

Problem

LKB-2502 The garbage collection of the project info cache is garbage.

What we observed: If we get unlucky, we might throw away a very hot entry if the cache is full. The GC loop is dependent on getting a lucky shard of the projects2ep table that clears a lot of cold entries. The GC does not take into account active use, and the interval it runs at is too sparse to do any good.

Can we switch to a proper cache implementation?

Complications:

  1. We need to invalidate by project/account.
  2. We need to expire based on retry_delay_ms.

Summary of changes

  1. Replace retry_delay_ms: Duration with retry_at: Instant when deserializing.
  2. Split the EndpointControls from the RoleControls into two different caches.
  3. Introduce an expiry policy based on error retry info.
  4. Introduce moka as a dependency, replacing our TimedLru.

See the follow up PR for changing all TimedLru instances to use moka: #12726.

Copy link

github-actions bot commented Jul 23, 2025

9031 tests run: 8381 passed, 0 failed, 650 skipped (full report)


Flaky tests (3)

Postgres 17

Postgres 16

Code coverage* (full report)

  • functions: 34.8% (8796 of 25290 functions)
  • lines: 45.8% (71313 of 155546 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
ef1c66b at 2025-07-25T10:37:41.766Z :recycle:

@conradludgate conradludgate force-pushed the conrad/replace-project-info-cache-with-moka branch 2 times, most recently from 4ef15ef to 5ded16f Compare July 24, 2025 15:37
@conradludgate conradludgate force-pushed the conrad/replace-project-info-cache-with-moka branch from 5ded16f to f018e66 Compare July 24, 2025 16:52
@conradludgate conradludgate marked this pull request as ready for review July 24, 2025 17:02
@conradludgate conradludgate requested a review from a team as a code owner July 24, 2025 17:02
@conradludgate conradludgate requested a review from awarus July 24, 2025 17:02
Copy link
Contributor

@awarus awarus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@awarus
Copy link
Contributor

awarus commented Jul 25, 2025

Some time ago we removed theCacheOutcome for the these caches. Do we need to measure cache hit/miss for new cache implementation?

@conradludgate
Copy link
Contributor Author

Some time ago we removed theCacheOutcome for the these caches. Do we need to measure cache hit/miss for new cache implementation?

Yeah, I'd like to reintroduce that - along with tracking how many items are in the caches. moka also lets you get notified when an item is removed so I think we can do something neat. Will make a follow up for that.

@conradludgate conradludgate added this pull request to the merge queue Jul 25, 2025
Merged via the queue into main with commit d19aebc Jul 25, 2025
102 checks passed
@conradludgate conradludgate deleted the conrad/replace-project-info-cache-with-moka branch July 25, 2025 11:49
github-merge-queue bot pushed a commit that referenced this pull request Jul 25, 2025
LKB-2536 TimedLru is hard to maintain. Let's use moka instead. Stacked
on top of #12710.
Copy link
Contributor

@kszafran kszafran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉

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.

3 participants