Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Thread-safe reference counts.
"Jon Harrop" <usenet@jdh30.plus.com> wrote in message
news:13uqrk9au723v0d@corp.supernews.com...
> jason.cipriani@gmail.com wrote: 
>
> A concurrent garbage collector is the appropriate way to handle that
> situation.

Why? There are many different ways to handle lifetime management.


Report this thread to moderator Post Follow-up to this message
Old Post
Chris Thomasson
03-29-08 12:18 AM


Re: Thread-safe reference counts.
Ian Collins wrote:
> Jon Harrop wrote: 
>
> One possible way, reference counted objects work just as well.

They are an order of magnitude slower and leak on cycles.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u

Report this thread to moderator Post Follow-up to this message
Old Post
Jon Harrop
03-29-08 03:14 AM


Re: Thread-safe reference counts.
Jon Harrop wrote:
> Ian Collins wrote: 
>
> They are an order of magnitude slower and leak on cycles.
>
Nonsense, show us the data.

--
Ian Collins.

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Collins
03-29-08 03:14 AM


Re: Thread-safe reference counts.
"Jon Harrop" <usenet@jdh30.plus.com> wrote in message
news:13ur7d6c6joov2d@corp.supernews.com...
> Ian Collins wrote: 
>
> They are an order of magnitude slower and leak on cycles.

What type of counting algorithm are you talking about? I know a certain type
of distributed reference counting can incur virtually zero-overheads. There
is also deferred counting, weighted counting, ect...


Report this thread to moderator Post Follow-up to this message
Old Post
Chris Thomasson
03-29-08 03:14 AM


Re: Thread-safe reference counts.
On 28 mar, 23:50, Ian Collins <ian-n...@hotmail.com> wrote:
> Jon Harrop wrote: 
 

> One possible way, reference counted objects work just as well.

That's wrong on two counts: first, reference counted objects
fail when cycles are present (which is almost always the case in
my code), and of course reference counting is more expensive in
terms of CPU time, especially in a multithreaded environment.
The latter is, of course, rarely a real problem.  The first,
however, pretty much means that there are cases where reference
counting can't be used.

If the problem is freeing memory, especially in a multithreaded
environment, using the Boehm collector with C++ is definitly the
simplest solution.  In his case, it sounds like
boost::shared_ptr would also be an effective solution.  The
additional runtime will probably not be noticeable, and from his
very general description, it doesn't should like there would be
cycles, or if there were, they should be easy to break.  (If
he's currently using neither, it's definitely easier to adopt
boost::shared_ptr---the Boehm collector requires some non
trivial configuration.  On the other hand, I find it worthwhile
to invest the effort, since the results are generally useful.)

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34

Report this thread to moderator Post Follow-up to this message
Old Post
James Kanze
03-29-08 01:08 PM


Re: Thread-safe reference counts.
On 29 mar, 02:58, Ian Collins <ian-n...@hotmail.com> wrote:
> Jon Harrop wrote: 
e 
 

> Nonsense, show us the data.

Well, they obviously leak if cycles are present.  And while "an
order of magnitude slower" is obviously false as well, Hans
Boehm has performed a number of benchmarks, and they are slower
in a lot of cases.

A lot depends on how you use dynamic memory.  The runtime of a
typical collector depends on the amount of memory actually in
use when the garbage collector runs; the runtime of a typical
manual memory allocator depends on the number of allocations and
frees.  An application which uses a lot of small, short lived
objects, and disposes of adequate memory, will run significantly
faster with garbage collection.  An application which only
allocates a few, very big object, will run faster with manual
collection or shared pointers.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34

Report this thread to moderator Post Follow-up to this message
Old Post
James Kanze
03-29-08 01:08 PM


Re: Thread-safe reference counts.
On 28 mar, 23:56, "Chris Thomasson" <cris...@comcast.net> wrote:
> "Jon Harrop" <use...@jdh30.plus.com> wrote in message

> news:13uqrk9au723v0d@corp.supernews.com...
 
 

> Why? There are many different ways to handle lifetime management.

Just to make it clear: the original posting talked about memory
management, not object lifetime management.  From the way it was
presented, it more or less sounded like object lifetime had no
significance (often the case).  In which case, garbage
collection is fine.  But garbage collection has nothing to do
with object lifetime (which, when significant, still must be
managed, garbage collection or not).

The original poster presented a very concrete problem, for which
garbage collection is probably the best solution, but for which
boost::shared_ptr would probably work almost as well.  If he's
already using one, but not the other, then the solution is
obvious.  If he's using both, I'd go with garbage collection:
less complexity and less actual coding.  If he's using neither,
it depends.  Boost::shared_ptr is definitly easier to introduce
into a project, but garbage collection is likely to have more
long term benefits.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34

Report this thread to moderator Post Follow-up to this message
Old Post
James Kanze
03-29-08 01:08 PM


Re: Thread-safe reference counts.
Ian Collins wrote:
> Jon Harrop wrote: 
>
> Nonsense, show us the data.

Read Jones and Lins "Garbage Collection" and references therein for a start.

Reference counting is very slow because updating reference counts requires
cache incoherent memory access, which is very slow on modern hardware and
is getting relatively slower every year as CPU speed increases faster than
memory speed. The slowdown is already enormous.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u

Report this thread to moderator Post Follow-up to this message
Old Post
Jon Harrop
03-30-08 12:21 AM


Re: Thread-safe reference counts.
James Kanze wrote:
[...]
> That's wrong on two counts: first, reference counted objects
> fail when cycles are present (which is almost always the case in
> my code), ...

See

http://www.open-std.org/JTC1/SC22/W...297.html#cycles

regards,
alexander.

Report this thread to moderator Post Follow-up to this message
Old Post
Alexander Terekhov
03-30-08 12:21 AM


Re: Thread-safe reference counts.
Jon Harrop wrote:
>
> Ian Collins wrote: 
>
> Read Jones and Lins "Garbage Collection" and references therein for a star
t.
>
> Reference counting is very slow because updating reference counts requires
> cache incoherent memory access, which is very slow on modern hardware and

"cache incoherent"? :-)

> is getting relatively slower every year as CPU speed increases faster than
> memory speed. The slowdown is already enormous.

You seem to presume heavy contention while copying and
modifying/destroying shared pointers (maintaining reference counts).

If that is the case, then running transaction in a separate address
space without any managed memory reclamation is surely best. No garbage
collection is needed. ;-)

regards,
alexander.

Report this thread to moderator Post Follow-up to this message
Old Post
Alexander Terekhov
03-30-08 12:21 AM


Sponsored Links




Last Thread Next Thread Next
Pages (11): « 1 2 3 [4] 5 6 7 8 9 » ... Last »
Search this forum -> 
Post New Thread

C++ archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:50 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.