How does Apple's Objective-C runtime do multithreaded reference counting without degraded performance?

后端 未结 2 845
夕颜
夕颜 2020-12-30 07:55

So I was reading this article about an attempt to remove the global interpreter lock (GIL) from the Python interpreter to improve multithreading performance and saw somethin

2条回答
  •  旧时难觅i
    2020-12-30 08:40

    In addition to what bbum said, a lot of the most frequently thrown around objects in Cocoa override the normal reference counting mechanisms and store a refcount inline in the object, which they manipulate with atomic add and subtract instructions rather than locking.

    (edit from the future: Objective-C now automatically does this optimization on modern Apple platforms, by mixing the refcount in with the 'isa' pointer)

提交回复
热议问题