Skip to content

Conversation

@cppcoffee
Copy link
Member

Replace manual mutex-protected bool with atomic.Bool for client.closed
to reduce lock contention and improve concurrent performance.

@codecov
Copy link

codecov bot commented Jun 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.88%. Comparing base (496c3ef) to head (bdca5a9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
- Coverage   65.00%   64.88%   -0.12%     
==========================================
  Files          27       27              
  Lines        2635     2626       -9     
==========================================
- Hits         1713     1704       -9     
  Misses        911      911              
  Partials       11       11              
Flag Coverage Δ
go 64.88% <100.00%> (-0.12%) ⬇️
wasm 41.66% <0.00%> (+0.14%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@JoeTurki JoeTurki left a comment

Choose a reason for hiding this comment

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

Sorry but I don’t see any upside to this change, and it breaks the invariants that keep Client safe.

closed is part of the state protected by the mutex. and moving its reads/writes outside the write section removes the guarantee that no new transactions can start after Close() is called, Also we'll have an edge condition where close side effects can trigger twice.

I don't see a hot path where switch to atomic.bool will have any performance win here. And during the client lifetime we still have to lock anyway.

Thank you for the improvements you've been making across the entire Pion codebase <3

@cppcoffee cppcoffee closed this Jun 29, 2025
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.

2 participants