Skip to content

Commit 621e84d

Browse files
committed
Peform non-incremental run on child commit as well.
1 parent 1c6f018 commit 621e84d

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

scripts/incremental/benchmarking/efficiency.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,30 @@ def analyze_small_commits_in_repo(cwd, outdir, from_c, to_c):
113113
add_options = default_options + ['--disable', 'incremental.load', '--enable', 'incremental.save']
114114
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, parent.hash, outparent, conf_base, add_options, files)
115115

116+
#print('And now analyze', str(commit.hash), 'from scratch.')
117+
outchild_non_incr = os.path.join(outtry, 'child-non-incr')
118+
os.makedirs(outchild_non_incr)
119+
# Do not save in this run to not pollute results
120+
add_options = default_options + ['--disable', 'incremental.load', '--disable', 'incremental.save']
121+
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchild_non_incr, conf_base, add_options, files)
122+
116123
#print('And now analyze', str(commit.hash), 'incrementally.')
117124
outchild = os.path.join(outtry, 'child')
118125
os.makedirs(outchild)
119126
add_options = default_options + ['--enable', 'incremental.load', '--disable', 'incremental.save']
120127
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchild, conf_base, add_options, files)
121128

122129
#print('And again incremental, this time with incremental postsolver')
123-
outchildincrpost = os.path.join(outtry, 'child-incr-post')
124-
os.makedirs(outchildincrpost)
130+
outchild_incr_post = os.path.join(outtry, 'child-incr-post')
131+
os.makedirs(outchild_incr_post)
125132
add_options = default_options + ['--enable', 'incremental.load', '--disable', 'incremental.save']
126-
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchildincrpost, conf_incrpost, add_options, files)
133+
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchild_incr_post, conf_incrpost, add_options, files)
127134

128135
#print('And again incremental, this time with incremental postsolver and reluctant')
129-
outchildrel = os.path.join(outtry, 'child-rel')
130-
os.makedirs(outchildrel)
136+
outchild_rel = os.path.join(outtry, 'child-rel')
137+
os.makedirs(outchild_rel)
131138
add_options = default_options + ['--enable', 'incremental.load', '--disable', 'incremental.save', '--enable', 'incremental.reluctant.enabled']
132-
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchildrel, conf_incrpost, add_options, files)
139+
utils.analyze_commit(analyzer_dir, gr, repo_path, build_compdb, commit.hash, outchild_rel, conf_incrpost, add_options, files)
133140

134141
count_analyzed+=1
135142
failed = False
@@ -149,18 +156,19 @@ def analyze_small_commits_in_repo(cwd, outdir, from_c, to_c):
149156

150157
def collect_data(outdir):
151158
data = {"Commit": [], "Failed?": [], "Changed LOC": [], "Relevant changed LOC": [], "Changed/Added/Removed functions": [],
152-
utils.runtime_header_parent: [], utils.runtime_header_incr_child: [],
159+
utils.runtime_header_parent: [], utils.runtime_header_non_incr_child: [], utils.runtime_header_incr_child: [],
153160
utils.runtime_header_incr_posts_child: [], utils.runtime_header_incr_posts_rel_child: [],
154-
utils.analysis_header_parent: [], utils.analysis_header_incr_child: [],
161+
utils.analysis_header_parent: [], utils.analysis_header_non_incr_child: [], utils.analysis_header_incr_child: [],
155162
utils.analysis_header_incr_posts_child: [], utils.analysis_header_incr_posts_rel_child: [],
156-
utils.solving_header_parent: [], utils.solving_header_incr_child: [],
163+
utils.solving_header_parent: [], utils.solving_header_non_incr_child: [], utils.solving_header_incr_child: [],
157164
utils.solving_header_incr_posts_child: [], utils.solving_header_incr_posts_rel_child: [],
158165
"Change in number of race warnings": []}
159166
for t in os.listdir(outdir):
160-
parentlog = os.path.join(outdir, t, 'parent', utils.analyzerlog)
161-
childlog = os.path.join(outdir, t, 'child', utils.analyzerlog)
162-
childpostslog = os.path.join(outdir, t, 'child-incr-post', utils.analyzerlog)
163-
childpostsrellog = os.path.join(outdir, t, 'child-rel', utils.analyzerlog)
167+
parent_log = os.path.join(outdir, t, 'parent', utils.analyzerlog)
168+
child_non_incr_log = os.path.join(outdir, t, 'child-non-incr', utils.analyzerlog)
169+
child_log = os.path.join(outdir, t, 'child', utils.analyzerlog)
170+
child_posts_log = os.path.join(outdir, t, 'child-incr-post', utils.analyzerlog)
171+
child_posts_rel_log = os.path.join(outdir, t, 'child-rel', utils.analyzerlog)
164172
commit_prop_log = os.path.join(outdir, t, 'commit_properties.log')
165173
t = int(t)
166174
commit_prop = json.load(open(commit_prop_log, "r"))
@@ -170,38 +178,45 @@ def collect_data(outdir):
170178
data["Commit"].append(commit_prop["hash"][:7])
171179
if commit_prop["failed"] == True:
172180
data[utils.runtime_header_parent].append(0)
181+
data[utils.runtime_header_non_incr_child].append(0)
173182
data[utils.runtime_header_incr_child].append(0)
174183
data[utils.runtime_header_incr_posts_child].append(0)
175184
data[utils.runtime_header_incr_posts_rel_child].append(0)
176185
data[utils.analysis_header_parent].append(0)
186+
data[utils.analysis_header_non_incr_child].append(0)
177187
data[utils.analysis_header_incr_child].append(0)
178188
data[utils.analysis_header_incr_posts_child].append(0)
179189
data[utils.analysis_header_incr_posts_rel_child].append(0)
180190
data[utils.solving_header_parent].append(0)
191+
data[utils.solving_header_non_incr_child].append(0)
181192
data[utils.solving_header_incr_child].append(0)
182193
data[utils.solving_header_incr_posts_child].append(0)
183194
data[utils.solving_header_incr_posts_rel_child].append(0)
184195

185196
data["Changed/Added/Removed functions"].append(0)
186197
data["Change in number of race warnings"].append(0)
187198
continue
188-
parent_info = utils.extract_from_analyzer_log(parentlog)
189-
child_info = utils.extract_from_analyzer_log(childlog)
190-
child_posts_info = utils.extract_from_analyzer_log(childpostslog)
191-
child_posts_rel_info = utils.extract_from_analyzer_log(childpostsrellog)
199+
200+
parent_info = utils.extract_from_analyzer_log(parent_log)
201+
child_non_incr_info = utils.extract_from_analyzer_log(child_non_incr_log)
202+
child_info = utils.extract_from_analyzer_log(child_log)
203+
child_posts_info = utils.extract_from_analyzer_log(child_posts_log)
204+
child_posts_rel_info = utils.extract_from_analyzer_log(child_posts_rel_log)
192205
data["Changed/Added/Removed functions"].append(int(child_info["changed"]) + int(child_info["added"]) + int(child_info["removed"]))
193206
data[utils.runtime_header_parent].append(float(parent_info["runtime"]))
207+
data[utils.runtime_header_non_incr_child].append(float(child_non_incr_info["runtime"]))
194208
data[utils.runtime_header_incr_child].append(float(child_info["runtime"]))
195209
data[utils.runtime_header_incr_posts_child].append(float(child_posts_info["runtime"]))
196210
data[utils.runtime_header_incr_posts_rel_child].append(float(child_posts_rel_info["runtime"]))
197211

198-
199212
data[utils.analysis_header_parent].append(float(parent_info["analysis_time"]))
213+
data[utils.analysis_header_non_incr_child].append(float(child_non_incr_info["analysis_time"]))
200214
data[utils.analysis_header_incr_child].append(float(child_info["analysis_time"]))
201215
data[utils.analysis_header_incr_posts_child].append(float(child_posts_info["analysis_time"]))
202216
data[utils.analysis_header_incr_posts_rel_child].append(float(child_posts_rel_info["analysis_time"]))
203217

204218
data[utils.solving_header_parent].append(float(parent_info["solving_time"]))
219+
data[utils.solving_header_non_incr_child].append(float(child_non_incr_info["solving_time"]))
205220
data[utils.solving_header_incr_child].append(float(child_info["solving_time"]))
206221
data[utils.solving_header_incr_posts_child].append(float(child_posts_info["solving_time"]))
207222
data[utils.solving_header_incr_posts_rel_child].append(float(child_posts_rel_info["solving_time"]))

scripts/incremental/benchmarking/plot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def cummulative_distr_compare2(results_dir, result_csv_filename, figure_dir):
1313
outfile_incr_vs_incrrel = "figure_cum_distr_rel.pdf"
1414
df = utils.get_cleaned_filtered_data(os.path.join(results_dir,result_csv_filename), filterDetectedChanges=True)
1515

16-
data, base = utils.create_cum_data(df, num_bins, [utils.runtime_header_parent, utils.runtime_header_incr_child, utils.runtime_header_incr_posts_rel_child])
16+
data, base = utils.create_cum_data(df, num_bins, [utils.runtime_header_non_incr_child, utils.runtime_header_incr_child, utils.runtime_header_incr_posts_rel_child])
1717
datanonincr = {"values": data[0], "label": description_non_incr}
1818
dataincr = {"values": data[1], "label": description_incr}
1919

@@ -30,7 +30,7 @@ def cummulative_distr_all4(results_dir, result_csv_filename, figure_dir):
3030
outfile_nonincr_vs_incr = "figure_cum_distr_all3.pdf"
3131
df = utils.get_cleaned_filtered_data(os.path.join(results_dir,result_csv_filename), filterDetectedChanges=True)
3232

33-
data, base = utils.create_cum_data(df, num_bins, [utils.runtime_header_parent, utils.runtime_header_incr_child, utils.runtime_header_incr_posts_child, utils.runtime_header_incr_posts_rel_child])
33+
data, base = utils.create_cum_data(df, num_bins, [utils.runtime_header_non_incr_child, utils.runtime_header_incr_child, utils.runtime_header_incr_posts_child, utils.runtime_header_incr_posts_rel_child])
3434
data_non_incr = {"values": data[0], "label": description_non_incr}
3535
data_incr = {"values": data[1], "label": description_incr}
3636
data_incr_post = {"values": data[2], "label": description_incr_post}
@@ -41,7 +41,7 @@ def distribution_absdiff_plot(title, result_csv_filename, outdir, cutoffs_incr=N
4141
df = utils.get_cleaned_filtered_data(os.path.join(outdir,result_csv_filename), filterDetectedChanges=True)
4242

4343
# plot incremental vs non-incremental
44-
diff = df.loc[:,utils.runtime_header_parent] - df.loc[:,utils.runtime_header_incr_child]
44+
diff = df.loc[:,utils.runtime_header_non_incr_child] - df.loc[:,utils.runtime_header_incr_child]
4545
utils.hist_plot(diff, 20, title, 'Improvement in s (incremental compared to non-incremental)', 'Number of Commits', os.path.join(outdir, "figure_absdiff_distr_incr.pdf"), cutoffs_incr)
4646

4747
# plot reluctant vs. basic incremental
@@ -53,7 +53,7 @@ def distribution_reldiff_plot(title, result_csv_filename, outdir, cutoffs_incr=N
5353

5454
# plot incremental vs non-incremental
5555
print(df[utils.runtime_header_incr_child].astype('float'))
56-
diff = 1 - df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_parent].astype('float')
56+
diff = 1 - df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
5757
utils.hist_plot(diff, 0.01, title, "Relative Improvement in s (incremental compared to non-incremental)", 'Number of Commits', os.path.join(outdir, "figure_reldiff_distr_incr.pdf"), cutoffs_incr)
5858

5959
# plot reluctant vs. basic incremental
@@ -62,10 +62,10 @@ def distribution_reldiff_plot(title, result_csv_filename, outdir, cutoffs_incr=N
6262

6363
def paper_efficiency_graphs(dir_results, csv_filename, outdir, filterRelCLOC=False, filterDetectedChanges=False):
6464
df = utils.get_cleaned_filtered_data(os.path.join(dir_results,csv_filename), filterRelCLOC=filterRelCLOC, filterDetectedChanges=filterDetectedChanges)
65-
diff1 = 1 - df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_parent].astype('float')
65+
diff1 = 1 - df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
6666
diff2 = 1 - df[utils.runtime_header_incr_posts_child].astype('float') / df[utils.runtime_header_incr_child].astype('float')
6767
diff3 = 1 - df[utils.runtime_header_incr_posts_rel_child].astype('float') / df[utils.runtime_header_incr_posts_child].astype('float')
68-
diff4 = 1 - df[utils.runtime_header_incr_posts_rel_child].astype('float') / df[utils.runtime_header_parent].astype('float')
68+
diff4 = 1 - df[utils.runtime_header_incr_posts_rel_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
6969
step = 0.01
7070
for i, diff in enumerate([diff1,diff2,diff3,diff4]):
7171
# output textwidth in latex with
@@ -97,9 +97,9 @@ def paper_efficiency_graphs(dir_results, csv_filename, outdir, filterRelCLOC=Fal
9797
for e in diff:
9898
if (xlimleft and e < xlimleft) or (xlimright and e > xlimright):
9999
print("excluded", e, "from efficiency figure", i)
100-
diff1 = df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_parent].astype('float')
101-
diff2 = df[utils.runtime_header_incr_posts_child].astype('float') / df[utils.runtime_header_parent].astype('float')
102-
diff3 = df[utils.runtime_header_incr_posts_rel_child].astype('float') / df[utils.runtime_header_parent].astype('float')
100+
diff1 = df[utils.runtime_header_incr_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
101+
diff2 = df[utils.runtime_header_incr_posts_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
102+
diff3 = df[utils.runtime_header_incr_posts_rel_child].astype('float') / df[utils.runtime_header_non_incr_child].astype('float')
103103
for n, diff in [("incr", diff1), ("+ incr postsolver", diff2), ("+ reluctant", diff3)]:
104104
print("80% quantile for", n, "compared to from-scratch analysis:", diff.quantile(q=0.8) * 100, "%")
105105
print("75% quantile for", n, "compared to from-scratch analysis:", diff.quantile(q=0.75) * 100, "%")

scripts/incremental/benchmarking/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,25 @@
3434
solving_prefix = "Solving"
3535

3636
header_parent = " for parent commit (non-incremental)"
37+
header_non_incr_child = " for commit (non-incremental)"
3738
header_incr_child = " for commit (incremental)"
3839
header_incr_posts_child = " for commit (incremental + incr postsolver)"
3940
header_incr_posts_rel_child = " for commit (incremental + incr postsolver + reluctant)"
4041

4142
runtime_header_parent = runtime_prefix + header_parent
43+
runtime_header_non_incr_child = runtime_prefix + header_non_incr_child
4244
runtime_header_incr_child = runtime_prefix + header_incr_child
4345
runtime_header_incr_posts_child = runtime_prefix + header_incr_posts_child
4446
runtime_header_incr_posts_rel_child = runtime_prefix + header_incr_posts_rel_child
4547

4648
analysis_header_parent = analysis_prefix + header_parent
49+
analysis_header_non_incr_child = analysis_prefix + header_non_incr_child
4750
analysis_header_incr_child = analysis_prefix + header_incr_child
4851
analysis_header_incr_posts_child = analysis_prefix + header_incr_posts_child
4952
analysis_header_incr_posts_rel_child = analysis_prefix + header_incr_posts_rel_child
5053

5154
solving_header_parent = solving_prefix + header_parent
55+
solving_header_non_incr_child = solving_prefix + header_non_incr_child
5256
solving_header_incr_child = solving_prefix + header_incr_child
5357
solving_header_incr_posts_child = solving_prefix + header_incr_posts_child
5458
solving_header_incr_posts_rel_child = solving_prefix + header_incr_posts_rel_child

0 commit comments

Comments
 (0)