4 ms·
The Swift compiler does lifetime and ownership analysis to eliminate many/most ARC overhead, beyond when things are truly shared between threads and the like.
by llm_nerd 1y ago
The Swift compiler does lifetime and ownership analysis to eliminate many/most ARC overhead, beyond when things are truly shared between threads and the like.
https://g.co/gemini/share/51670084cd0f https://g.co/gemini/share/51670084cd0f - lame, but it references core concepts.
- cyberax 1y agoI'm not sure how it can detect that outside of trivial cases. Any object that is passed into a library function can escape the current thread, unless the compiler can analyze all the binary at once.
- slavapestov 1y ago> Any object that is passed into a library function can escape the current thread, In Swift 6 this is only true if the value’s type is Sendable.
- llm_nerd 1y agoMany (and increasingly most) Swift libraries are largely Swift modules delivered as SIL (Swift Intermediate Language). The compiler can indeed trace right into those calls and determine object lifetime and if it escapes. It is far more comprehensive than often presumed. Though the vast majority of cases where ARC would come into play are of the trivial variety.
- elpakal 1y agousername checks out