[concurrency-interest] Default Stack Size on 64-bit JVMs

David M. Lloyd david.lloyd at redhat.com
Mon Dec 7 07:38:05 EST 2015


On 12/07/2015 04:40 AM, Andrew Haley wrote:
> On 02/12/15 20:25, Jorge Branco wrote:
>>> Has it been considered to eliminate the use of recursion entirely from
>>> the concurrency library (or for that matter the JDK) ?  Any need for
>>> recursion can be readily transformed into the use of a stack.
>>
>> Wouldn't that entail a huge performance cost? Some very raw experiments
>> I've done in the past seemed to imply that a (Java) stack would give a
>> terrible performance in comparison with equivalent algorithms using plain
>> recursion.
>
> I can't immediately see any reason it should.  There's no way to tell
> for sure without real code.

Using ArrayDeque instead of Stack would be a good first step, as the 
latter uses synchronization everywhere.  Also, proper initial sizing is 
very important to performance for large operations to avoid copying.
-- 
- DML


More information about the Concurrency-interest mailing list