Skip to content

Redesign actor_addr as value type - #2409

Merged
Neverlord merged 1 commit into
mainfrom
gh-2397-actor-addr-redesign
Sep 29, 2026
Merged

Neverlord merged 1 commit into
mainfrom
gh-2397-actor-addr-redesign

Conversation

@Neverlord

Copy link
Copy Markdown
Member

The only purpose of actor_addr is to select actor handles that are stored as either actor or typed_actor<...>. However, internally it holds a weak pointer to the actor. At this point, only for historic reasons.

While holding a weak pointer internally works in a single-process setting, this design breaks in a distributed system. Sending a weak pointer is deeply problematic:

  • remote nodes hold strong references to actors they are communicating with; once the remote actor terminates this reference will be dropped automatically from the registry
  • when receiving a weak pointer to an unknown actor, there is no sensible thing the receiver might do other than discarding it:
    • creating a proxy would immediately expire the object again
    • there might exist weak references to the old proxy, creating a new one would mean those pointer would be unequal even though they represent the same actor
    • storing weak references in the registry would only introduce new problems w.r.t. proxy lifetimes, etc.

Since the purpose of actor_addr is to identify terminated actors in an exit_msg or down_msg, the much cleaner, safe alternative is to re-implement it as a simple value type holding an actor_id and a node_id: these two IDs uniquely and unambiguously identify any actor in a distributed CAF system.

Since sending weak pointers is fundamentally unsafe, we also remove the type ID for weak_actor_ptr.

This comment was marked as outdated.

@codecov

codecov Bot commented May 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.86364% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.16%. Comparing base (42882ae) to head (44d0bf1).

Files with missing lines Patch % Lines
libcaf_core/caf/actor_addr.cpp 51.51% 15 Missing and 1 partial ⚠️
libcaf_core/caf/detail/compare.cpp 78.57% 4 Missing and 2 partials ⚠️
libcaf_core/caf/actor_addr.hpp 77.27% 3 Missing and 2 partials ⚠️
libcaf_io/caf/io/basp_broker.cpp 16.66% 5 Missing ⚠️
libcaf_core/caf/attachable.cpp 77.77% 2 Missing and 2 partials ⚠️
libcaf_core/caf/abstract_actor.cpp 84.21% 2 Missing and 1 partial ⚠️
libcaf_core/caf/actor.cpp 33.33% 1 Missing and 1 partial ⚠️
libcaf_core/caf/detail/monitor_action.cpp 0.00% 0 Missing and 2 partials ⚠️
libcaf_core/caf/typed_actor.hpp 84.61% 1 Missing and 1 partial ⚠️
libcaf_core/caf/send.hpp 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2409      +/-   ##
==========================================
- Coverage   73.21%   73.16%   -0.05%     
==========================================
  Files         654      654              
  Lines       31533    31561      +28     
  Branches     3450     3458       +8     
==========================================
+ Hits        23087    23092       +5     
- Misses       6489     6507      +18     
- Partials     1957     1962       +5     

☔ View full report in Codecov by Harness.
📢 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.

@Neverlord
Neverlord force-pushed the gh-2397-actor-addr-redesign branch 2 times, most recently from 26449e4 to 793424d Compare May 3, 2026 09:03
@Neverlord
Neverlord requested a review from Copilot May 3, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libcaf_core/caf/actor_addr.hpp Outdated
Comment thread CHANGELOG.md
@Neverlord
Neverlord force-pushed the gh-2397-actor-addr-redesign branch from 793424d to 6ba4690 Compare May 3, 2026 09:29
@Neverlord
Neverlord force-pushed the gh-2397-actor-addr-redesign branch 2 times, most recently from 8e9a1fb to 6dea1ca Compare September 25, 2026 07:50
The only purpose of `actor_addr` is to select actor handles that are
stored as either `actor` or `typed_actor<...>`. However, internally it
holds a weak pointer to the actor. At this point, only for historic
reasons.

While holding a weak pointer internally works in a single-process
setting, this design breaks in a distributed system. Sending a weak
pointer is deeply problematic:
- remote nodes hold *strong* references to actors they are communicating
  with; once the remote actor terminates this reference will be dropped
  automatically from the registry
- when receiving a weak pointer to an unknown actor, there is no
  sensible thing the receiver might do other than discarding it:
  * creating a proxy would immediately expire the object again
  * there might exist weak references to the old proxy, creating a new
    one would mean those pointer would be unequal even though they
    represent the same actor
  * storing weak references in the registry would only introduce new
    problems w.r.t. proxy lifetimes, etc.

Since the purpose of `actor_addr` is to identify terminated actors in an
`exit_msg` or `down_msg`, the much cleaner, safe alternative is to
re-implement it as a simple value type holding an `actor_id` and a
`node_id`: these two IDs uniquely and unambiguously identify any actor
in a distributed CAF system.

Further, sending weak pointers is fundamentally unsafe. Hence, we also
remove the type ID for `weak_actor_ptr` and remove support for it from
the serialization API.
@Neverlord
Neverlord force-pushed the gh-2397-actor-addr-redesign branch from 6dea1ca to 44d0bf1 Compare September 25, 2026 08:06
@Neverlord
Neverlord marked this pull request as ready for review September 28, 2026 14:04
@Neverlord
Neverlord requested a review from riemass September 28, 2026 14:04

@riemass riemass left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, approving.

@Neverlord
Neverlord merged commit 9fccef5 into main Sep 29, 2026
15 checks passed
@Neverlord
Neverlord deleted the gh-2397-actor-addr-redesign branch September 29, 2026 09:40
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