CurtHagenlocher commented on issue #540:
URL: https://github.com/apache/arrow-dotnet/issues/540#issuecomment-7417129705

   One more argument for retaining: it would make releasing a buffer cheaper.
   
   Today, copies of an `ArrowBuffer` share a single reference, and so do a 
plain `Slice` and its original. Any of them can release that reference, so 
releasing a handle has to be safe when it happens more than once, even on 
several threads at the same time. That costs an atomic exchange on top of the 
shared count's atomic decrement (#538).
   
   If each holder retained a reference of its own, each would release a 
different handle. Disposing different holders at the same time would then 
contend only on the shared count. A handle's own release wouldn't need to be 
atomic, as with any .NET object whose `Dispose` isn't promised to be 
thread-safe. Releasing a buffer would cost one atomic operation, the same as in 
Arrow C++ (`shared_ptr`), arrow-rs (`Arc`) and Arrow Go (`Retain`/`Release`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to