|
The most common data-race... Here's the most common data-race I see:
This is just my personal observation, both on code I've written and code other people have written but I've had to debug. This is the most common race, by far. Annoyingly, the race can be removed by an optimizing compiler - sometimes. That is, the standard common-subexpression-elimination optimization will remove the redundant loads of ' The other problem with this code, is that you are normally solving a Large Complex Problem already - and concurrency is your tool to get the needed performance. In order to solve the Large Complex Problem (LCP) at all you've added a few layers of abstraction to hide it's complexity - which inadvertently hides the complexity of the concurrent algorithm! Suppose '
Aha! Now you (don't) see the problem... good software engineering of the LCP has obscured the racey concurrent code. Even worse: 'method->flush()' is a rare event, so this race is even rarer... meaning you'll only crash on a heavy trading day with the VP of engineering breathing down your neck and never in the development cycle! Here's an even more obscure version of the same wrong code:
We just set the code variable, so it's still set when we read it again to execute it - right? Wrong! Or maybe 'Almost but not quite!'. What's the fix? Acknowledging that the concurrent algorithm is just as complex as LCP (perhaps less code than the LCP but generally more subtle code). Expose the shared variables and concurrent accesses explicitly. Make them part of the good software engineering solution that's going on for the LCP already.
Cliff TrackBackTrackBack URL for this entry: Listed below are links to weblogs that reference The most common data-race...: CommentsPost a comment |


