Conversation
1. ractor/src/pg.rs — Full rewrite of PgState and all functions
New GroupState struct bundles members and per-group listeners into one atomically-accessible unit:
struct GroupState {
members: HashMap<ActorId, ActorCell>,
listeners: Vec<ActorCell>,
}
New PgState uses three maps instead of the old three separate maps:
- map: DashMap<ScopeGroupKey, GroupState> — unified members + per-group listeners
- index: DashMap<ScopeName, HashSet<GroupName>> — secondary index (now uses HashSet instead of Vec)
- world_listeners: DashMap<ScopeGroupKey, Vec<ActorCell>> — scope-level/global monitors only
Key fixes:
- Cross-map inconsistency (#1): Members and per-group listeners are now in one entry, atomically updated
- Zombie actor insertion (#3): join_scoped filters out actors with status > Draining
- Notifications under lock (#4): All functions clone listeners and drop entry guards before sending notifications
- leave_all misses global monitors (#5): New notify_world_listeners helper checks both scoped and ALL_SCOPES_NOTIFICATION keys
- demonitor_scope incomplete (#6): Now removes from world_listeners directly (clean)
- monitor_scope duplicate notifications (#7): Registers ONLY in world_listeners, not also per-group
- leave_all cleanup race (#9): Re-checks emptiness under entry lock before removing
2. ractor/src/actor/actor_cell.rs — Guard double cleanup (#8)
Added && self.get_status() < ActorStatus::Stopping condition so cleanup only runs once on the first transition to Stopping, avoiding redundant full-DashMap iterations.
3. ractor/src/pg/tests.rs — 3 new tests
- test_monitor_scope_no_duplicate_notifications — verifies exactly 1 notification when monitor_scope is called after group exists
- test_demonitor_scope_fully_unsubscribes — verifies no notifications after demonitor_scope
- test_stopped_actor_not_inserted — verifies stopped actors are rejected by join
Resolves #374
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #411 +/- ##
==========================================
+ Coverage 85.56% 85.73% +0.16%
==========================================
Files 73 73
Lines 13329 13361 +32
==========================================
+ Hits 11405 11455 +50
+ Misses 1924 1906 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchmark Comparison (PR vs
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New GroupState struct bundles members and per-group listeners into one atomically-accessible unit: struct GroupState { members: HashMap<ActorId, ActorCell>, listeners: Vec, }
New PgState uses three maps instead of the old three separate maps:
Key fixes:
Added && self.get_status() < ActorStatus::Stopping condition so cleanup only runs once on the first transition to Stopping, avoiding redundant full-DashMap iterations.
Resolves #374