Skip to content

Handle ThreadContext cache more cleanly #13530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented May 27, 2025

Switch to a concurrent backing collection. Note that we only ever create them if you ask for them on the current thread.

Microsoft Reviewers: Open in CodeFlow

Switch to a concurrent backing collection. Note that we only ever create them if you ask for them on the current thread.
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner May 27, 2025 17:27
@JeremyKuhne JeremyKuhne requested review from Copilot and removed request for a team May 27, 2025 17:27
Copy link
Contributor

@Copilot 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 improves thread-safety by switching from a Dictionary with manual locking to a ConcurrentDictionary in the ThreadContext cache.

  • Replace manual locking with concurrent operations for thread context management.
  • Remove unnecessary locks in DisposeInternal, ExitApplication, and Create methods as the backing collection is now thread-safe.

Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 45.45455% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.59963%. Comparing base (9a17505) to head (1f61d78).
Report is 2 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13530         +/-   ##
===================================================
+ Coverage   76.59478%   76.59963%   +0.00485%     
===================================================
  Files           3230        3230                 
  Lines         639165      639148         -17     
  Branches       47297       47295          -2     
===================================================
+ Hits          489567      489585         +18     
+ Misses        146015      145987         -28     
+ Partials        3583        3576          -7     
Flag Coverage Δ
Debug 76.59963% <45.45455%> (+0.00485%) ⬆️
integration 18.78823% <18.18182%> (+0.00112%) ⬆️
production 51.00649% <45.45455%> (+0.00930%) ⬆️
test 97.40411% <ø> (ø)
unit 48.40417% <45.45455%> (+0.01019%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

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

LGTM, too.

@JeremyKuhne JeremyKuhne merged commit 9db17fd into dotnet:main May 27, 2025
9 checks passed
@JeremyKuhne JeremyKuhne deleted the contextCache branch May 27, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants