[concurrency-interest] Advice on reuse of ForkJoinTask instances

√iktor Ҡlang viktor.klang at gmail.com
Tue Mar 20 18:03:53 EDT 2012


Would it make sense to use a status bit for "resubmit" in the general sense?

Cheers,
√

2012/3/20 √iktor Ҡlang <viktor.klang at gmail.com>

>
>
> On Tue, Mar 20, 2012 at 11:47 AM, Doug Lea <dl at cs.oswego.edu> wrote:
>
>> On 03/19/12 12:52, √iktor Ҡlang wrote:
>>
>>> We're using the latest incarnation of the ForkJoinPool in Akka,
>>> and I was looking at reducing allocations in the hot path, and
>>> essentially the
>>> only thing left to remove is to remove the creation of a FJT for every
>>> submission (and we have _lots_ of those), but unfortunately it seems
>>> rather
>>> non-straightforward as I'll have to call reinitialize at the end of
>>> executing
>>> the FJT.
>>>
>>>
>> There are a few common cases where it is easy and effective
>> to reuse FJTs, for example when building trees of recurring
>> computations. (The FJJacobi program in our CVS src/tests/loops
>> has one example.) But in most other cases, GC will do a better
>> job of managing space than you can. FJ is extremely friendly
>> to generational collectors -- most tasks become garbage and
>> reclaimable almost immediately, and managing the others is done
>> better using GC mechanics than almost anything else you could do.
>>
>> Usually a better tactic is to minimize any auxiliary object
>> creation needed to start or process a task. Often enough,
>> these other objects are less GC-friendly. Among other steps,
>> it is usually worthwhile to "flatten" tasks so that they
>> contain all necessary state for execution without creating other
>> transient objects. For example, in graph algorithms, it often
>> works nicely to make each node itself a ForkJoinTask.
>>
>
> We're talking about _alot_ of submissions here :-)
> To get 0 allocations in my hot path I'd want to be able to resubmit the
> current FJT,
> I can probably implement it myself, but I believe that it could be useful
> for others as well.
>
> Cheers,
>>
>
>>
>> -Doug
>>
>>
>> ______________________________**_________________
>> Concurrency-interest mailing list
>> Concurrency-interest at cs.**oswego.edu <Concurrency-interest at cs.oswego.edu>
>> http://cs.oswego.edu/mailman/**listinfo/concurrency-interest<http://cs.oswego.edu/mailman/listinfo/concurrency-interest>
>>
>
>
>
> --
> Viktor Klang
>
> Akka Tech Lead
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang
>
>


-- 
Viktor Klang

Akka Tech Lead
Typesafe <http://www.typesafe.com/> - The software stack for applications
that scale

Twitter: @viktorklang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120320/c7fc7ce3/attachment.html>


More information about the Concurrency-interest mailing list