Skip to content

fix: eliminate L1 cache defensive copy#131

Merged
poyrazK merged 2 commits intomainfrom
fix/l1-cache-no-copy
May 2, 2026
Merged

fix: eliminate L1 cache defensive copy#131
poyrazK merged 2 commits intomainfrom
fix/l1-cache-no-copy

Conversation

@poyrazK
Copy link
Copy Markdown
Owner

@poyrazK poyrazK commented May 2, 2026

Summary

  • Add Cache.GetInto() method that injects TXID directly into shared cache entry
  • Eliminate ~50MB/s allocations at 100K qps by removing make+copy on L1 hit
  • Lock held through send to prevent concurrent mutation

Changes

  • cache.go: Add GetInto() that injects TXID into shared entry, holds shard RLock
  • server.go: Use GetInto() instead of Get() + mutation, keep per-key lock through send

Test plan

  • go build ./... passes
  • go test -short ./... passes

Cache.GetInto() injects TXID directly into shared cache entry,
avoiding the make+copy allocation on every L1 hit. Lock is held
through send to prevent concurrent mutation of shared entry.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Warning

Rate limit exceeded

@poyrazK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 50 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fefccccf-1ca3-42a5-b6df-19700b1a89d3

📥 Commits

Reviewing files that changed from the base of the PR and between 63322f8 and d0dda4a.

📒 Files selected for processing (2)
  • internal/dns/server/cache.go
  • internal/dns/server/server.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/l1-cache-no-copy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 35 minutes and 50 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

The fromL2 bool was replaced with a nil check on cachedData since
the variable is already populated when L2 provides data.
Copy link
Copy Markdown
Owner Author

@poyrazK poyrazK left a comment

Choose a reason for hiding this comment

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

It's okay to merge

@poyrazK poyrazK merged commit 55d7a28 into main May 2, 2026
7 checks passed
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