Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

Reduce memory consumption by avoiding adding items when queue is full

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • If any gains or losses in performance are possible, you've included benchmarks for your changes. More info
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

EventBasedLRUCache cleanup: remove TaskCount and simplify code

Description

Under heavy load, stress tests showed the LRUCache was unable to keep up. Items are now rejected when the cache is full or compacting to prevent kernel object accumulation when SignatureProviders aren't actually cached.

Source Changes

EventBasedLRUCache.cs

  • Removed _taskCount field and TaskCount property (task now starts once in constructor)
  • Simplified compaction state check from Interlocked.CompareExchange to direct read
  • Converted methods to expression-bodied members
  • Cleaned up XML documentation

InMemoryCryptoProviderCache.cs

  • Removed TaskCount property

InternalAPI.Shipped.txt / InternalAPI.Unshipped.txt

  • Removed TaskCount API entries from both classes

Test Changes

CryptoProviderFactoryTests.cs

  • Removed tests dependent on TaskCount: ProviderCache_EnsureNoException_MultipleThreads, ProviderCache_EnsureNoLeakingTasks_SecurityTokenHandler_*
  • Removed associated helper methods

Fixes #3239


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix memory consumption by avoiding adding items when queue is full Reduce memory consumption by avoiding adding items when queue is full Dec 2, 2025
Copilot AI requested a review from pmaytak December 2, 2025 17:18
Copilot finished work on behalf of pmaytak December 2, 2025 17:18
@pmaytak pmaytak deleted the copilot/sub-pr-3374 branch December 3, 2025 23:29
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