Skip to content

llo/datasource: consistent cache expiry calculation, reduce lock contention#21224

Open
calvwang9 wants to merge 2 commits intodevelopfrom
llo-datasource-cache-fixes
Open

llo/datasource: consistent cache expiry calculation, reduce lock contention#21224
calvwang9 wants to merge 2 commits intodevelopfrom
llo-datasource-cache-fixes

Conversation

@calvwang9
Copy link
Contributor

follow up to #21189

  • AddMany: ensure consistent expiry time calculation across an atomic batch add
  • Get and GetMany: reduce lock contention by moving prom metric updates outside of the read lock

@github-actions
Copy link
Contributor

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@trunk-io
Copy link

trunk-io bot commented Feb 18, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cl-sonarqube-production
Copy link

@calvwang9 calvwang9 marked this pull request as ready for review February 18, 2026 13:06
@calvwang9 calvwang9 requested review from a team as code owners February 18, 2026 13:06
Copilot AI review requested due to automatic review settings February 18, 2026 13:06
@calvwang9 calvwang9 requested review from akuzni2 and brunotm and removed request for namikmesic February 18, 2026 13:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a follow-up to PR #21189 that improves the LLO datasource observation cache implementation. It focuses on two specific optimizations: ensuring consistent expiry time calculation across batch operations and reducing lock contention during cache reads.

Changes:

  • Modified AddMany to calculate expiry time once before the loop, ensuring all items in a batch have identical expiry timestamps
  • Refactored Get and GetMany methods to defer Prometheus metric updates until after releasing read locks, reducing lock contention
  • Added comprehensive concurrency tests for AddMany and combined AddMany/GetMany operations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/services/llo/observation/cache.go Refactored Add/AddMany to calculate expiry before locking; moved metric updates outside read locks in Get/GetMany
core/services/llo/observation/cache_test.go Added TestCache_ConcurrentAddMany and TestCache_ConcurrentAddManyGetMany to verify thread safety

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Comments