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
719bed6d
Commit
719bed6d
authored
Jan 31, 2017
by
Christian Dietrich
Browse files
historical: restrict the number of cache misses to the actual compilation
parent
05f48bde
Changes
2
Show whitespace changes
Inline
Side-by-side
experiments/historical_build.py
View file @
719bed6d
...
...
@@ -90,10 +90,6 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
"commit-hash"
:
self
.
metadata
[
"project-hash"
],
'builds'
:
[]}
hash_log
=
self
.
tmp_directory
.
new_file
(
"clang-hash.log"
)
if
"clang-hash"
in
self
.
mode
.
value
:
os
.
environ
[
"CLANG_HASH_LOGFILE"
]
=
hash_log
.
path
with
self
.
project
as
src_path
:
(
commits
,
_
)
=
shell
(
"cd %s; git log --no-merges --oneline --topo-order --format='%%H %%P %%s'"
,
src_path
)
# [0] is hash. [1] is parent, [2] rest
...
...
@@ -151,13 +147,6 @@ class HistoricalCompilation(Experiment, ClangHashHelper):
with
open
(
self
.
stats
.
path
,
"w+"
)
as
fd
:
fd
.
write
(
repr
(
self
.
build_info
))
if
"ccache"
in
self
.
mode
.
value
:
shell
(
"ccache -s > %s"
,
self
.
ccache_stats
.
path
)
# Copy Log to the result directory
with
open
(
hash_log
.
path
)
as
fd
:
self
.
clang_hash_stats
.
value
=
fd
.
read
()
def
variant_name
(
self
):
return
"%s-%s"
%
(
self
.
project_name
(),
self
.
metadata
[
'mode'
])
...
...
experiments/lib.py
View file @
719bed6d
...
...
@@ -3,6 +3,7 @@ import fnmatch
import
time
from
versuchung.execute
import
shell
,
CommandFailed
,
shell_failok
import
logging
import
tempfile
def
read_hash_directory
(
hash_dir
,
remove_keys
=
[]):
"""Read in all records from a hash dir
...
...
@@ -88,7 +89,25 @@ class ClangHashHelper:
else
:
return
shell
(
"cd %s; make -j %s"
,
path
,
str
(
self
.
jobs
.
value
))
def
ccache_hits
(
self
):
(
lines
,
_
)
=
shell
(
"ccache -s"
)
ccache_hits
=
0
ccache_misses
=
0
for
line
in
lines
:
if
"cache hit"
in
line
and
"rate"
not
in
line
:
ccache_hits
+=
int
(
line
[
line
.
index
(
")"
)
+
1
:].
strip
())
if
"cache miss"
in
line
:
ccache_misses
+=
int
(
line
[
line
.
index
(
"miss"
)
+
4
:].
strip
())
return
ccache_hits
,
ccache_misses
def
rebuild
(
self
,
path
,
info
,
fail_ok
=
False
):
if
"ccache"
in
self
.
mode
.
value
:
old_ccache_hits
,
old_ccache_misses
=
self
.
ccache_hits
()
if
"clang-hash"
in
self
.
mode
.
value
:
hash_log
=
tempfile
.
NamedTemporaryFile
()
os
.
environ
[
"CLANG_HASH_LOGFILE"
]
=
hash_log
.
name
# Recompile!
start_time
=
time
.
time
()
try
:
...
...
@@ -101,9 +120,20 @@ class ClangHashHelper:
ret
=
(
""
,
1
)
end_time
=
time
.
time
()
# Account only nano seconds, everywhere
build_time
=
int
((
end_time
-
start_time
)
*
1e9
)
info
[
'build-time'
]
=
build_time
# Record Cache misses and hits
if
"ccache"
in
self
.
mode
.
value
:
ccache_hits
,
ccache_misses
=
self
.
ccache_hits
()
info
[
'ccache-hits'
]
=
ccache_hits
-
old_ccache_hits
info
[
'ccache-misses'
]
=
ccache_misses
-
old_ccache_misses
if
"clang-hash"
in
self
.
mode
.
value
:
log
=
hash_log
.
read
()
info
[
'clang-hash-hits'
]
=
log
.
count
(
"H"
)
info
[
'clang-hash-misses'
]
=
log
.
count
(
"M"
)
logging
.
info
(
"Rebuild done[%s]: %s s; failed=%s"
,
info
.
get
(
"filename"
)
or
info
.
get
(
"commit"
),
build_time
/
1e9
,
...
...
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