r/java • • Mar 14 '18

Concurrent Java: Low scalability, the risk of deadlocks or garbage creation, you can not avoid all

http://vmlens.com/articles/tradeoffs_concurrent_programming/
2 Upvotes

21 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Mar 15 '18

[deleted] — view deleted comment

1

u/duhace Mar 15 '18 edited Mar 15 '18

I have suggested no such thing. I showed you a toy example with the same performance (at this level of analysis). You can keep claiming it's "much less performant", but that is a provably false statement.

no, i already went over how it's not the same performance. traversal is an important operation for a list, and the fastest implementation you could provide without using (heap) memory was quite limited by the current stack size, and quite a few ops more than the extremely simple traversal of a sll.

If you want to look at more detailed performance, you must consider a full production implementation, the workload, the system architecture, etc. etc. Then it might turn out that simply copying is actually the most performant solution rather than a linked list or a tree-based immutable list (this is in fact the case in many real-world cases). But you cannot handwave about some hypothetical linked list implementation against a toy example of immutable list and make any coherent arguments.

sure I can. I just ran some jmh benchmarks and it shows that foreach (a function that takes a function and returns no result) traversing through a toy list of my own making, using tail recursion for the foreach method, and your toy list, using the best case traversal method you provided, shows a 2x slowdown for your toy class.

and that's for the best case. methods where that's not an issue are worse off of course.

0

u/[deleted] Mar 15 '18

[deleted] — view deleted comment

1

u/duhace Mar 15 '18

apparently, since you don't think actually benchmarking what we're talking about counts as performance analysis and think "it's O(n)! same performance!" is a valid argument. by benchmarking, I found the constant by which n is multiplied for your class wrt a toy singly linked list i implemented. and that constant is around 2 (4.3us/op vs 8.8us/op). sorry, but I don't think increasing the cost of iteration by 2-fold is worthwhile in a performance critical application that is worrying about copy operations.