On 7/21/2010 12:58 PM, Gregg Wonderly wrote:
...
When I write code of this nature, attempting to remove all contention, I
try
to list every "step" that changes the "view" of the world, and think about
how that "view" can be made atomic by using explicit ordering of statements
rather than synchronized{} blocks.  ...

I would like to discuss how to approach performance improvement, and especially scaling improvement. We seem to have different philosophies, and I'm interested in understanding other people's approaches to programming.

I try to first find the really big wins, which are almost always data structure and algorithm changes. That should result in code that is efficient in terms of total CPU time and memory. During that part of the process, I prefer to keep the concurrency design as simple as possible, which in Java often means using synchronization at a coarse level, such as synchronization on a TaskManager instance.

Once that is done, I review the performance. If it is fast and scalable I stop there. If that is not the case, I look for the bottlenecks, and consider whether parallelism, or some other strategy, will best improve them. Any increase in concurrency complication has to be justified by a demonstrated improvement in performance.

My big picture objective is to find the simplest implementation that meets the performance requirements (or cannot reasonably be made significantly faster, if the requirement is just "make it fast"). I value simplicity in concurrency design over simplicity in data structures or algorithms for two reasons:

1. Making the code more parallel does nothing to reduce the total resources is uses. Better algorithms, on the other hand, can significantly reduce total resources.

2. Reasoning about data structures and algorithms is generally easier than reasoning about concurrency.

It sounds as though you are advocating almost the opposite approach - aim for maximum concurrency from the start, without analysis or measurement to see what it gains, or even having a baseline implementation for comparison. Is that accurate? If so, could you explain the thinking and objectives behind your approach? Or maybe I'm misunderstanding, and you can clarify a bit?

Thanks,

Patricia

Reply via email to