Does this allow somehow to sidestep this? Since the data is all thread-local, it should be possible to use non-atomic counters?
Does this allow somehow to sidestep this? Since the data is all thread-local, it should be possible to use non-atomic counters?
Swift introduced bunch of ownership keywords to help you to use value objects for most of the needs to sidestep reference-counting and minimize copying.
Of course, to my understanding, "actor" in Swift is a "class"-like object, so it will be reference-counted. But I fail to see how that is different from other systems (as actor itself has to be mutable, hence, a reference object anyway).
Example here: https://forums.swift.org/t/noncopyable-generics-in-swift-a-c...
An added plus is that the Swift compiler seems to stack-promote a lot more often, compared to class/ManagedBuffer implementations.
See https://dl.acm.org/doi/10.1145/3243176.3243195:
“BRC is based on the observation that most objects are only accessed by a single thread, which allows most RC operations to be performed non-atomically. BRC leverages this by biasing each object towards a specific thread, and keeping two counters for each object --- one updated by the owner thread and another updated by the other threads. This allows the owner thread to perform RC operations non-atomically, while the other threads update the second counter atomically.“
(I don’t know whether Swift uses this at the moment)
https://g.co/gemini/share/51670084cd0f - lame, but it references core concepts.
In Swift 6 this is only true if the value’s type is Sendable.
Though the vast majority of cases where ARC would come into play are of the trivial variety.
https://stackoverflow.com/questions/25542416/swift-with-no-a...