On ordering problems in message passing software

Yuheng Long, Mehdi Bagherzadeh, Eric Lin, Ganesha Upadhyaya, Hridesh RajanMODULARITY 2016

TL;DR

Message passing is crucial for modern concurrent software, but asynchronous communication can lead to subtle "message ordering problems" that cause hard-to-debug bugs. This paper systematically analyzes how different semantic choices in message passing paradigms (synchronization, delivery, sharing) impact these ordering problems across various concurrent programming patterns, providing valuable insights for developers and framework designers.

What Problem Does This Paper Address?

Modern software increasingly relies on concurrency, and the message passing paradigm offers a modular and scalable way to achieve it. In this paradigm, processes communicate by sending and receiving messages, often asynchronously for better performance. However, this asynchronous nature introduces a significant challenge: the order in which messages are sent in the program text might not be the order in which they are processed by the receiving process. This discrepancy, known as the "message ordering problem," can lead to bugs that are notoriously difficult to find and debug because they depend on the non-deterministic timing of message delivery and processing, often violating programmer assumptions based on sequential code. The paper aims to understand and quantify the relationship between these ordering problems and the various semantic choices available in message passing systems.

Methods

The authors propose a systematic approach to study message ordering problems. They identify three key semantic criteria that influence these problems:

  • C1: Message Synchronization Semantics: Whether message sends are synchronous (blocking until processed) or asynchronous (non-blocking).
  • C2: Message Delivery and Processing Semantics: Whether messages are delivered and processed in a guaranteed order (in-order) or in an arbitrary, nondeterministic order.
  • C3: Sharing Semantics: Whether processes share data directly (data sharing) or operate on independent copies (data isolation).

They define five message passing models based on combinations of these semantics (base, +sync, +inorder, +trans, +isol). To analyze these models, they develop a static analysis technique that constructs a "system graph" representing processes, message exchanges, happens-before relations (causal ordering of operations), and memory effects. By analyzing these system graphs for "unsafe interleavings" (operations without a happens-before relation but with conflicting memory effects), they can detect potential message ordering problems.

Datasets

The paper uses a collection of 34 benchmark applications, totaling approximately 130,000 lines of code. These benchmarks are adapted from previous work and include well-known sources like NAS Parallel Benchmarks and parallel JavaGrande, covering various concurrent programming patterns such as Master Worker, Loop Parallelism, Pipeline, and Event-based Coordination. The authors refactored these applications into the message passing language Panini for their analysis.

Key Insights and Ideas

  • Semantic Choices Matter Greatly: The presence and severity of message ordering problems are highly dependent on the specific semantic configurations of the message passing paradigm. For instance, in-order delivery and processing (C2) and data isolation (C3) are particularly effective in preventing these issues.
  • Critical Semantics Vary by Pattern: Different concurrent programming patterns benefit more from specific semantic features. For example, Event-based Coordination heavily relies on in-order messaging, while Loop Parallelism benefits from synchronous messaging and data isolation.
  • Overlapping Prevention: While some ordering problems can only be prevented by a single semantic configuration (making that configuration "critical" for a given pattern), many can be addressed by multiple configurations, indicating redundancy and flexibility.
  • Minimal Test Cases: A significant portion of ordering problems can be triggered with very few processes (often just 2) and messages (often just 1 or 2), which is crucial for efficient testing and debugging.
  • Unresolved Problems Exist: Even with the most robust semantic configurations, a percentage of ordering problems remain unresolved, suggesting the need for further techniques like commutativity guarantees.

Key Results

The paper quantifies the effectiveness of different semantic models in preventing ordering problems across various patterns. For example:

  • In Event-based Coordination, (+inorder and +sync) prevent 97% of ordering problems.
  • In Pipeline applications, +inorder alone prevents 100% of ordering problems.
  • Across all patterns, +sync prevents the most ordering problems overall (70%), followed by +inorder (53%) and +isol (36%).
  • More than half of ordering problems can be triggered with only 2 processes.
  • Over three-quarters of problems in +trans, base, and +isol are triggered by only 2 messages.

Limitations and Future Work

Limitations: * External Validity: The study is based on a specific set of benchmark applications and patterns, so general conclusions about all message passing systems might not be directly applicable. * Internal Validity: The refactoring process, while designed to be syntactic, might introduce subtle differences. The analysis also cannot detect manual implementations of synchronous messaging or in-order delivery using asynchronous primitives.

Future Work: The authors suggest exploring other problems in message passing programming beyond ordering issues. They also mention the potential for future work to study the impact of these findings on application developers, verifiers, and framework designers, and to investigate how to handle the remaining unresolved ordering problems.

Summary updated

BibTeX
@inproceedings{long2016ordering,
  author = {Yuheng Long and Mehdi Bagherzadeh and Eric Lin and Ganesha Upadhyaya and Hridesh Rajan},
  title = {{On ordering problems in message passing software}},
  booktitle = {MODULARITY},
  year = {2016},
  doi = {10.1145/2889443.2889444},
}
Figure