Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Dietrich
clang-hash
Commits
db0b379d
Commit
db0b379d
authored
Jan 24, 2017
by
Ludwig Fueracker
Browse files
Merge branch 'master' of gitlab.cs.fau.de:stettberger/clang-hash
parents
35fa8ec9
ece0b874
Pipeline
#3047
passed with stage
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
experiments/Makefile
View file @
db0b379d
...
...
@@ -22,7 +22,7 @@ inc_$3_$2_append:
inc_$3_$2_touch
:
./incremental_rebuild.py
-s
\
-d
../versuchung-data
--jobs
$(JOBS)
\
-v
v
--clang_hash-clone-url
${CLANG_HASH}
\
-v
--clang_hash-clone-url
${CLANG_HASH}
\
--project-clone-url
${
$1
}
--mode
$2
--touch-only
true
inc_$3
:
inc_$3_$2_touch inc_$3_$2_append
...
...
@@ -34,3 +34,23 @@ endef
$(foreach
project,MUSL
POSTGRESQL
CPYTHON
MBEDTLS
LUA
BASH
SAMBA,\
$(foreach
mode,normal
ccache
clang-hash,\
$(eval $(call inc_template,$(project),$(mode),$(shell echo $(project) | tr '[
:
upper:]' '[:lower:]' )))))
define
hist_template
hist_$3_$2
:
./historical_build.py
-s
\
-d
../versuchung-data
--jobs
$(JOBS)
\
-v
--clang_hash-clone-url
${CLANG_HASH}
\
--project-clone-url
${
$1
}
--mode
$2
--commits
500
hist_$3
:
hist_$3_$2
endef
$(foreach
project,LUA
MBEDTLS
SAMBA
MUSL
POSTGRESQL
CPYTHON,\
$(foreach
mode,normal
ccache
clang-hash
ccache-clang-hash,\
$(eval $(call hist_template,$(project),$(mode),$(shell echo $(project) | tr '[
:
upper:]' '[:lower:]' )))))
analyze
:
./analyze_results.py
-v
-d
../versuchung-data
-s
\
--result
'../versuchung-data/IncrementalCompilation-*'
experiments/analyze_results.py
0 → 100755
View file @
db0b379d
#!/usr/bin/env python2
import
os
import
re
import
sys
import
logging
import
time
from
itertools
import
groupby
from
collections
import
defaultdict
tmp_path
=
"%s/git/versuchung/src"
%
os
.
environ
[
"HOME"
]
if
os
.
path
.
exists
(
tmp_path
):
sys
.
path
.
append
(
tmp_path
)
from
versuchung.experiment
import
Experiment
from
versuchung.types
import
String
,
Bool
,
Integer
,
List
from
versuchung.files
import
File
,
Directory
from
versuchung.execute
import
shell
from
versuchung.tex
import
DatarefDict
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.patches
as
mpatches
from
incremental_rebuild
import
IncrementalCompilation
from
historical_build
import
HistoricalCompilation
class
AnalyzeResults
(
Experiment
):
inputs
=
{
'incremental'
:
List
(
IncrementalCompilation
(),
[]),
'historical'
:
List
(
HistoricalCompilation
(),
[]),
}
outputs
=
{
'tex'
:
DatarefDict
(
'data.dref'
)}
def
save
(
self
,
path
,
value
):
self
.
tex
[
'/'
.
join
(
path
)]
=
value
logging
.
info
(
"%s = %s"
,
'/'
.
join
(
path
),
value
)
def
run
(
self
):
self
.
project_name
=
""
x
=
sorted
(
self
.
incremental
,
key
=
lambda
x
:
x
.
project_name
())
for
(
project
,
results
)
in
groupby
(
x
,
key
=
lambda
x
:
x
.
project_name
()):
times
=
defaultdict
(
lambda
:
dict
())
for
result
in
sorted
(
results
,
key
=
lambda
x
:
x
.
variant_name
()):
records
=
eval
(
result
.
stats
.
value
)
build_times_all
=
[]
build_times_headers
=
[]
build_times_sources
=
[]
for
build
in
records
[
'builds'
]:
t
=
build
[
'build-time'
]
/
1e9
fn
=
re
.
sub
(
".*?/project/"
,
""
,
build
[
'filename'
])
times
[
fn
][
result
.
method_name
()]
=
t
if
build
[
'filename'
]
==
"FRESH_BUILD"
:
self
.
save
([
result
.
variant_name
(),
"fresh build"
],
t
)
continue
# Get a float in seconds
build_times_all
.
append
(
t
)
if
build
[
'filename'
].
endswith
(
'.h'
):
build_times_headers
.
append
(
t
)
else
:
build_times_sources
.
append
(
t
)
#print(build['id'])
def
seq
(
key
,
seq
):
self
.
save
(
key
+
[
"count"
],
len
(
seq
))
self
.
save
(
key
+
[
"avg"
],
np
.
average
(
seq
))
seq
([
result
.
variant_name
(),
'rebuild'
],
build_times_all
)
seq
([
result
.
variant_name
(),
'rebuild'
,
"sources"
],
build_times_sources
)
seq
([
result
.
variant_name
(),
'rebuild'
,
"headers"
],
build_times_headers
)
def
score
(
x
):
return
times
[
x
][
'touch-clang-hash'
]
/
times
[
x
][
'touch-normal'
]
x
=
sorted
(
times
,
key
=
score
)
best
=
x
[
0
]
print
(
project
,
best
,
score
(
best
),
times
[
best
])
################################################################
# Historical Build Times
################################################################
x
=
sorted
(
self
.
historical
,
key
=
lambda
x
:
x
.
project_name
())
for
(
project
,
results
)
in
groupby
(
x
,
key
=
lambda
x
:
x
.
project_name
()):
times
=
defaultdict
(
lambda
:
dict
())
for
result
in
sorted
(
results
,
key
=
lambda
x
:
x
.
variant_name
()):
records
=
eval
(
result
.
stats
.
value
)
build_times
=
[]
for
build
in
records
[
'builds'
]:
t
=
build
[
'build-time'
]
/
1e9
build_times
.
append
(
t
)
times
[
build
[
'commit'
]][
result
.
metadata
[
'mode'
]]
=
t
def
seq
(
key
,
seq
):
self
.
save
(
key
+
[
"sum"
],
sum
(
seq
))
self
.
save
(
key
+
[
"count"
],
len
(
seq
))
self
.
save
(
key
+
[
"avg"
],
np
.
average
(
seq
))
seq
([
result
.
variant_name
(),
'historical'
],
build_times
)
try
:
x
=
sorted
(
times
,
key
=
lambda
x
:
times
[
x
][
'clang-hash'
]
/
times
[
x
][
'normal'
])
print
(
project
,
x
[
0
],
times
[
x
[
0
]][
'clang-hash'
]
/
times
[
x
[
0
]][
'normal'
],
times
[
x
[
0
]])
except
:
pass
if
__name__
==
"__main__"
:
experiment
=
AnalyzeResults
()
dirname
=
experiment
(
sys
.
argv
+
[
"-s"
])
experiments/historical_build.py
View file @
db0b379d
...
...
@@ -22,7 +22,7 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
"clang_hash"
:
GitArchive
(
"/home/stettberger/w/clang-hash/"
),
"project"
:
GitArchive
(
"/home/stettberger/w/clang-hash/hash-projects/lua"
),
"mode"
:
String
(
"normal"
),
"commits"
:
Integer
(
50
),
"commits"
:
Integer
(
50
0
),
"jobs"
:
Integer
(
4
),
}
outputs
=
{
...
...
@@ -31,13 +31,14 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
def
run
(
self
):
# Determine the mode
modes
=
(
'normal'
,
'ccache'
,
'clang-hash'
)
modes
=
(
'normal'
,
'ccache'
,
'clang-hash'
,
'ccache-clang-hash'
)
if
not
self
.
mode
.
value
in
modes
:
raise
RuntimeError
(
"Mode can only be one of: %s"
%
modes
)
logging
.
info
(
"Build the Clang-Hash Plugin"
)
with
self
.
clang_hash
as
cl_path
:
shell
(
"cd %s; mkdir build; cd build; cmake ..; make -j 4"
,
cl_path
)
shell
(
"cd %s; mkdir build; cd build; cmake .. -DCMAKE_BUILD_TYPE=Release; make -j 4"
,
cl_path
)
shell
(
"strip %s/build/src/*.so"
,
cl_path
)
# Project name
logging
.
info
(
"Cloning project... %s"
,
self
.
project_name
())
...
...
@@ -54,7 +55,6 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
# clang hash wrapper
self
.
setup_compiler_paths
(
cl_path
)
while
True
:
commit
=
commits
.
pop
(
0
)
logging
.
info
(
"Build: %s"
,
commit
)
...
...
experiments/incremental_rebuild.py
View file @
db0b379d
...
...
@@ -97,11 +97,14 @@ class IncrementalCompilation(Experiment, ClangHashHelper):
with
open
(
self
.
stats
.
path
,
"w+"
)
as
fd
:
fd
.
write
(
repr
(
self
.
build_info
))
def
variant
_name
(
self
):
def
method
_name
(
self
):
mod
=
"append"
if
self
.
metadata
[
'touch-only'
]:
mod
=
"touch"
return
"%s-%s-%s"
%
(
self
.
project_name
(),
mod
,
self
.
metadata
[
'mode'
])
return
"%s-%s"
%
(
mod
,
self
.
metadata
[
'mode'
])
def
variant_name
(
self
):
return
"%s-%s"
%
(
self
.
project_name
(),
self
.
method_name
())
def
symlink_name
(
self
):
return
"%s-%s"
%
(
self
.
title
,
self
.
variant_name
())
...
...
experiments/lib.py
View file @
db0b379d
...
...
@@ -48,10 +48,12 @@ class ClangHashHelper:
def
call_configure
(
self
,
path
):
if
self
.
project_name
()
==
"postgresql"
:
shell
(
"cd %s; ./configure --enable-depend"
,
path
)
elif
self
.
project_name
()
in
(
"musl"
,
"cpython"
,
"bash"
,
"samba"
):
elif
self
.
project_name
()
in
(
"musl"
,
"bash"
,
"samba"
):
shell
(
"cd %s; ./configure"
,
path
)
elif
self
.
project_name
()
in
(
"cpython"
,):
shell
(
"cd %s; mkdir build; cd build; ../configure"
,
path
)
elif
self
.
project_name
()
in
(
'mbedtls'
):
shell
(
"cd %s; cmake . -DCMAKE_C_COMPILER=$CC"
,
path
)
shell
(
"cd %s;
mkdir build; cd build;
cmake .
.
-DCMAKE_C_COMPILER=$CC"
,
path
)
elif
self
.
project_name
()
in
(
'lua'
,):
# This is an ugly hack to make it possible to override the
# CC variable from the outsite.
...
...
@@ -68,7 +70,10 @@ class ClangHashHelper:
raise
RuntimeError
(
"Not a valid project"
)
def
call_make
(
self
,
path
):
return
shell
(
"cd %s; make -j %s"
,
path
,
str
(
self
.
jobs
.
value
))
if
self
.
project_name
()
in
(
"mbedtls"
,
"cpython"
):
return
shell
(
"cd %s/build; make -j %s"
,
path
,
str
(
self
.
jobs
.
value
))
else
:
return
shell
(
"cd %s; make -j %s"
,
path
,
str
(
self
.
jobs
.
value
))
def
rebuild
(
self
,
path
,
info
,
fail_ok
=
False
):
# Recompile!
...
...
experiments/plots.py
deleted
100755 → 0
View file @
35fa8ec9
#!/usr/bin/env python2
import
os
import
sys
import
logging
import
time
tmp_path
=
"%s/git/versuchung/src"
%
os
.
environ
[
"HOME"
]
if
os
.
path
.
exists
(
tmp_path
):
sys
.
path
.
append
(
tmp_path
)
from
versuchung.experiment
import
Experiment
from
versuchung.types
import
String
,
Bool
,
Integer
,
List
from
versuchung.files
import
File
,
Directory
from
versuchung.execute
import
shell
from
versuchung.tex
import
DatarefDict
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.patches
as
mpatches
from
incremental_rebuild
import
IncrementalCompilation
class
IncrementalCompilationPlots
(
Experiment
):
inputs
=
{
'results'
:
List
(
IncrementalCompilation
(),
[])}
outputs
=
{
'tex'
:
DatarefDict
(
'data.dref'
)}
def
save
(
self
,
path
,
value
):
self
.
tex
[
'/'
.
join
(
path
)]
=
value
logging
.
info
(
"%s = %s"
,
'/'
.
join
(
path
),
value
)
def
run
(
self
):
self
.
project_name
=
""
for
result
in
sorted
(
self
.
results
,
key
=
lambda
x
:
(
x
.
variant_name
())):
records
=
eval
(
result
.
stats
.
value
)
build_times_all
=
[]
build_times_headers
=
[]
build_times_sources
=
[]
for
build
in
records
[
'builds'
]:
t
=
build
[
'build-time'
]
/
1e9
if
build
[
'filename'
]
==
"FRESH_BUILD"
:
self
.
save
([
result
.
variant_name
(),
"fresh build"
],
t
)
continue
# Get a float in seconds
build_times_all
.
append
(
t
)
if
build
[
'filename'
].
endswith
(
'.h'
):
build_times_headers
.
append
(
t
)
else
:
build_times_sources
.
append
(
t
)
#print(build['id'])
def
seq
(
key
,
seq
):
self
.
save
(
key
+
[
"count"
],
len
(
seq
))
self
.
save
(
key
+
[
"avg"
],
np
.
average
(
seq
))
seq
([
result
.
variant_name
(),
'rebuild'
],
build_times_all
)
seq
([
result
.
variant_name
(),
'rebuild'
,
"sources"
],
build_times_sources
)
seq
([
result
.
variant_name
(),
'rebuild'
,
"headers"
],
build_times_headers
)
if
__name__
==
"__main__"
:
experiment
=
IncrementalCompilationPlots
()
dirname
=
experiment
(
sys
.
argv
+
[
"-s"
])
print
(
dirname
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment