Andrii Vozniuk
If I had to make decision only between treating all data races as bugs or treating them all as not bugs, I would select the first one. The reason is simple: this approach is safe. If we eliminate all data races, we can guarantee that harmful data races don't happen. In the opposite case, if we treat all data races as not bugs, occurrence of harmful bugs is possible. But as the question is whether all data races should be considered bugs or not, my definite position is that not all data races are erroneous and accepting specific kinds of data races can provide benefits to a program. For instance, benign data races are often left intentionally to achieve better performance. As they do not affect correctness of the program, it's not necessary to introduce all the overhead related to synchronization. One example of leaving data races for better performance is usage of caches. Consider several threads (or processes) accessing the same cache and at least one of them writes to the cache. Depending on the implementation, the cache may allow adding several instances of the same object and may be tolerant to being unable to find object in the cache after it was added. Due to multithreading, the cache may encounter additional misses but usually it is not a serious problem and makes no harm to the program. Another example when data races are acceptable, are programs relying on non-blocking algorithms. These algorithms allow concurrent update of shared data structures without using locks provided by operating system to protect critical sections. Although based on the definition of data races from the OP problem statement these algorithms do contain data races, they do not have negative impact on the program. A problem I see in handling specific data-race occurring in the code, is identifying whether or not this data race is potentially harmful. Promising research is done in this direction. For instance, in [1] main patterns for benign data races were identified. The authors proposed to use this information for making decision about harmfulness of the particular data-race. To sum up, I think some types of data races can be tolerated as long as they are not harmful and are advantageous for the program.
References:
|