[Development] Container refactor update

joao.abecasis at nokia.com joao.abecasis at nokia.com
Tue Jun 19 12:49:59 CEST 2012


Thiago Macieira wrote:
> Performance considerations:
> * ref() does two 1-bit tests before the atomic increment
> * deref() does one 1-bit test before the atomic decrement
> * needsDetach() does one 2-bit test and a check for the refcount's value

I think these are the operations that can afford to be "expensive". All of them are done where we're potentially i) allocating memory and copying data (e.g. unsharable data), ii) destroying elements and releasing memory (e.g. last owner), or iii) detaching for mutating data (e.g., shared data).

needsDetach and condition iii) above is where we could potentially save some by skipping the checks altogether under fairly limited and user-controlled situations with the oft-mentioned ref-counted-but-not-checked base class.

Cheers,


João




More information about the Development mailing list