Optimizing Solution Quality in Synchronization Synthesis

Pavol Cerný, Edmund M. Clarke, Thomas A. Henzinger, Arjun Radhakrishna, Leonid Ryzhyk, Roopsha Samanta, Thorsten TarracharXiv 2015

Abstract

Writing correct concurrent code is a significant challenge in software engineering. While automated synchronization synthesis tools exist to insert locks and fix concurrency bugs, they often employ "greedy" strategies that prioritize correctness over performance, leading to suboptimal code. This paper introduces O-LISS, a framework that decouples bug discovery from lock placement. By utilizing global constraints and statistical performance models, O-LISS synthesizes synchronization that is not only correct and deadlock-free but also optimized for specific hardware and workloads. Evaluation on real-world systems code demonstrates that O-LISS effectively balances concurrency and overhead.

Introduction

Concurrent programming is notoriously error-prone. Developers often aim for "preemption-safe" logic—code that remains correct even when threads are interrupted by a scheduler. When bugs occur, existing synthesis tools typically find a single counter-example and insert a lock to fix it. This iterative, greedy approach often results in "clunky" synchronization: either too many locks (high overhead) or locks that are too large (low concurrency). O-LISS addresses this by moving toward a global optimization strategy for synchronization synthesis.

The O-LISS Methodology

The O-LISS framework transitions away from local fixes toward a holistic view of program constraints. The process involves three primary stages:

  1. Constraint Extraction: Using a Counter-Example Guided Inductive Synthesis (CEGIS) loop, the tool identifies a complete set of mutual exclusion (mutex) requirements.
  2. Global Encoding: These requirements, alongside rules for deadlock-freedom and legitimate locking (e.g., avoiding double-locking), are encoded into a set of global constraints using an SMT (Satisfiability Modulo Theories) formula.
  3. Optimization: O-LISS selects the optimal lock placement from the set of valid solutions. This can be done syntactically (e.g., minimizing the number of lock statements) or through performance-based profiling that accounts for runtime contention and overhead.
The O-LISS synthesis workflow, illustrating the CEGIS loop for constraint extraction and the final synthesis of optimized locks.

Performance-Driven Optimization

A key insight of this work is that the "best" locking strategy is context-dependent. While fine-grained locking generally increases concurrency, it also introduces higher overhead. In scenarios with low contention or high locking costs, coarse-grained locking may be superior.

O-LISS uses a statistical model based on runtime profiling to predict execution times for different strategies. As shown in the performance evaluation, the execution time for coarse vs. fine-grained locking varies significantly depending on the workload intensity.

Performance comparison of coarse, mixed, and fine-grained locking strategies across varying workloads.

Evaluation and Results

The researchers evaluated O-LISS on two significant benchmarks: the TI CPMAC Ethernet Driver and Memcached (v1.4.5).

  • Scalability: O-LISS successfully synthesized synchronization for modules of approximately 1,000 lines of code within minutes.
  • Accuracy: In Memcached tests, the tool's performance model accurately predicted runtimes across 12 different workloads.
  • Optimization: The tool automatically adjusted between coarse and fine locking for Memcached based on data size, a task that typically requires intensive manual engineering.
  • Correctness: O-LISS fixed defects in the CPMAC driver that previous tools missed or resolved incorrectly by introducing deadlocks.

Conclusion and Future Work

O-LISS demonstrates that synchronization synthesis can go beyond mere bug-fixing to provide high-quality, performance-tuned solutions. By incorporating deadlock-freedom as a hard constraint and using global optimization, it produces more maintainable and efficient code. Future work includes extending the framework to support other primitives like read-write locks and automating the decomposition of programs for profiling.

Summary updated

BibTeX
@misc{cerny2015optimizing,
  author = {Pavol Cerný and Edmund M. Clarke and Thomas A. Henzinger and Arjun Radhakrishna and Leonid Ryzhyk and Roopsha Samanta and Thorsten Tarrach},
  title = {{Optimizing Solution Quality in Synchronization Synthesis}},
  year = {2015},
  eprint = {1511.07163},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1511.07163},
}
Figure