[fpc-devel] Suggestion: reference counted objects

Peter Popov ppopov99 at gmail.com
Mon Sep 22 22:32:44 CEST 2014


On Mon, 22 Sep 2014 21:34:34 +0300, Boian Mitov <mitov at mitov.com> wrote:

> Strongly disagree...
> For multithreading and parallel processing ARC is lifesaver. I have been  
> using it trough interfaces for 10 years already, and once I rewrote the  
> old code to use ARC it was a huge performance boost, and it keeps  
> getting better.

What on earth has reference counting got to do with writing efficient  
multi-threaded code? You obviously confuse parallel performance, which  
reference counting will obviously degrade, with making some particular  
coding style easier. And sure, if your threads don't use shared resources  
they will be very parallel indeed.

If your argument is that by writing less code you have more time to  
refactor code, therefore you write better algorithms, and they run better  
- then this would be a valid point for your situation. However, one size  
does not fit all. I am not going to re-profile code because suddenly  
assignments will not only incur a (possibly virtual) function call but  
also lock other threads even if for a cycle or two. Not to mention cache  
misses because every time you assign a pointer its value must be fetched  
 from memory and incremented, therefore messing around with data which was  
supposed to be in the cache. And screw other threads' caches.

To put it differently, ARC will seriously degrade applications which fill  
the memory bus bandwidth, multi-threaded or otherwise. For such pieces of  
code it should not be used.

Peter



More information about the fpc-devel mailing list