<jupyter_start><jupyter_text>Finding and fixing a mismatch between the Go memory model and data-race detector.  A story on applied formal methods<NAME>an<EMAIL> <EMAIL>https://github.com/dfava/paper.go.mm.drd<jupyter_code>import re
import operator
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from matplotlib import rc

rc('font',**{'family': 'serif', 'serif': ['Computer Modern'],'size' : 18})
rc('text', usetex=True)
class Experiment:
    def __init__(self, fname, info=None):
        assert(type(fname)==str)
        assert(info == None or type(info)==dict)
        self.fname = fname
        self.info = info
        self.data = None

    def len(self):
        return len(self.data['ops'])

    def parse(self, verbose=False):
        fhandle = open(self.fname, 'r')
        lines = fhandle.readlines()
        fhandle.close()
        s = re.compile('\S*, ops=(.*), procs=(.*)/(.*), locks=(.*), VC procs=(.*)/(.*), VC locks=(.*)/(.*)')
        self.data = {
                'name'  : self.fname,
                'ops'   : [],
                'procs' : { 'active' : [], 'total' : [], 'vc total' : [] }, 
                'locks' : {                'total' : [], 'vc total' : [] },
               }
        for lnum, line in enumerate(lines):
            m = s.match(line)
            if m:
                self.data['ops'].append(int(m.group(1)))
                self.data['procs']['active'].append(int(m.group(2)))
                self.data['procs']['total'].append(int(m.group(3)))           
                self.data['locks']['total'].append(int(m.group(4)))
                self.data['procs']['vc total'].append(int(m.group(6)))
                self.data['locks']['vc total'].append(int(m.group(8)))
                continue
        if verbose:
            max_ = 4
            print(self.data['ops'][0:max_])
            print(self.data['procs']['vc total'][0:max_])
            print(self.data['locks']['vc total'][0:max_])
expsFT = [
    Experiment('../data/sortnp.ft.out', info={'go' : {'sz' : 10000, 'N' : 40}, 'rd' : None}),
    Experiment('../data/sortnp.fix.ft.out',    info={'go' : {'sz' : 10000, 'N' : 40}, 'rd' : None}),
        ]
for exp in expsFT:
    exp.parse(verbose=True)
    print()
start=0
end=min(len(expsFT[0].data['ops']), len(expsFT[1].data['ops']))
fig, ax = plt.subplots()

ax.plot(expsFT[0].data['ops'][start:end], expsFT[0].data['locks']['vc total'][start:end], color='black')
ax.plot(expsFT[1].data['ops'][start:end], expsFT[1].data['locks']['vc total'][start:end], linestyle='--', color='black')
ax.set_ylabel('VC entries')
ax.set_xlabel('Instructions executed')
ax.grid()
fig.canvas.draw()
labels = [item.get_text() for item in ax.get_xticklabels()]
print(labels)
xlabels = ['', '0', '5M', '10M', '15M', '20M']
_ = ax.set_xticklabels(xlabels)
ylabels = ['', '0', '2K', '4K', '6K', '8K', '10K']
_ = ax.set_yticklabels(ylabels)
plt.savefig("vcentries.pdf", bbox_inches='tight')<jupyter_output>['$-0.5$', '$0.0$', '$0.5$', '$1.0$', '$1.5$', '$2.0$', '$2.5$']
{'fraction_non_alphanumeric': 0.22214897824653923, 'fraction_numerical': 0.02043506921555702, 'mean_word_length': 2.822418136020151, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '170693', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1082, 'n_words': 200, 'path': 'src/analysis.ipynb', 'repo_name': 'dfava/paper.go.mm.drd', 'size': '3062'}