{'fraction_non_alphanumeric': 0.031318923687692984, 'fraction_numerical': 0.008381120423467137, 'mean_word_length': 5.113207547169812, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Practically Making Threads Deterministic and Stable

Multithreaded programs are hard to get right. A key reason is that the contract between developers and runtimes grants exponentially many schedules to the runtimes. Two approaches improve correctness by reducing schedules. Deterministic multithreading (DMT) reduces schedules for each input down to one. Stable multithreading (SMT) reduces schedules for all inputs, increasing coverage of checking tools and providing broader repeatability than just determinism (e.g., “similar inputs lead to similar behaviors” and “adding debug printf doesn’t mask bugs”). However, despite years of effort, two difficult questions remain open. First, can the DMT and SMT approaches consistently achieve good performance on a wide range of programs? Second, can the approaches be made simple and adoptable? These concerns are not helped much by the limited evaluation of prior systems. We present PARROT, a simple, practical runtime that makes threads deterministic and stable by offering a new contract to developers. By default, it runs synchronizations in each thread in the well-defined round-robin order vastly reducing schedules and providing broad repeatability. When default schedules are slow, it allows advanced developers to write intuitive performance hints in code to switch or add schedules for speed. We believe this “meet in the middle” contract makes it easier to write correct, efficient programs. We further present an ecosystem formed by integrating PARROT with a model checker called DBUG. This ecosystem is more effective than either system alone: DBUG checks the schedules that matter to PARROT, and PARROT greatly increases the coverage of DBUG. Results on a diverse set of 108 programs, roughly one order of magnitude more than any prior evaluation, show that PARROT is easy to use (averaging 1.2 lines of hints per program); achieves low overhead (8.3% for 55 real-world programs and 19.5% for all 108 programs), many times better than two prior systems; scales well to maximum allowed cores on a 24-core server and to different scales/types of workloads; and increases coverage of DBUG by at least 10 for most programs. PARROT’s source code, entire benchmark suite, and results are at http://anonymized.