Skip to content

Commit 1070ab7

Browse files
committed
Use -H:BuildOutputJSONFile to get data from the native image builder
* Instead of parsing the output.
1 parent 6cebc0c commit 1070ab7

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

ci.jsonnet

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ local part_definitions = {
7171

7272
build: {
7373
setup+: [["mx", "sversions"]] +
74-
# aot-build.log is used for the build-stats metrics, in other cases it does no harm
75-
jt(["build", "--env", self.mx_env] + self.mx_options + ["--"] + self.mx_build_options + ["|", "tee", "aot-build.log"]) +
74+
jt(["build", "--env", self.mx_env] + self.mx_options + ["--"] + self.mx_build_options) +
7675
[
7776
# make sure jt always uses what was just built
7877
["set-export", "RUBY_BIN", jt(["--use", self.mx_env, "--silent", "launcher"])[0]],

mx.truffleruby/native

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ GRAALVM_SKIP_ARCHIVE=true
22
DYNAMIC_IMPORTS=/tools,/compiler,/substratevm
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM compiler,SubstrateVM,Native Image
44
NATIVE_IMAGES=suite:sulong,lib:rubyvm
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json
56
# To also create the standalone
67
INSTALLABLES=TruffleRuby

mx.truffleruby/native-ee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ GRAALVM_SKIP_ARCHIVE=true
22
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,SubstrateVM Enterprise
44
NATIVE_IMAGES=suite:sulong,lib:rubyvm
5-
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+AuxiliaryEngineCache rubyvm:-H:ReservedAuxiliaryImageBytes=1073741824
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:+AuxiliaryEngineCache rubyvm:-H:ReservedAuxiliaryImageBytes=1073741824
66
# To also create the standalone
77
INSTALLABLES=TruffleRuby

mx.truffleruby/native-ee-g1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ GRAALVM_SKIP_ARCHIVE=true
22
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,SubstrateVM Enterprise,SubstrateVM Enterprise GC
44
NATIVE_IMAGES=suite:sulong,lib:rubyvm
5-
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+UseG1GC
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:+UseG1GC
66
# To also create the standalone
77
INSTALLABLES=TruffleRuby

mx.truffleruby/native-host-inlining

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ GRAALVM_SKIP_ARCHIVE=true
22
DYNAMIC_IMPORTS=/tools,/compiler,/substratevm
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM compiler,SubstrateVM,Native Image
44
NATIVE_IMAGES=lib:rubyvm
5-
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:Log=HostInliningPhase,~CanonicalizerPhase,~GraphBuilderPhase rubyvm:-H:+TruffleHostInliningPrintExplored rubyvm:-Dgraal.LogFile=host-inlining.txt
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:Log=HostInliningPhase,~CanonicalizerPhase,~GraphBuilderPhase rubyvm:-H:+TruffleHostInliningPrintExplored rubyvm:-Dgraal.LogFile=host-inlining.txt
66
# To also create the standalone
77
INSTALLABLES=TruffleRuby

tool/jt.rb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,11 +1727,11 @@ def build_stats(attribute, *args)
17271727

17281728
value = case attribute
17291729
when 'binary-size'
1730-
build_stats_native_binary_size(*args)
1730+
build_stats_native_binary_size
17311731
when 'build-time'
1732-
build_stats_native_build_time(*args)
1732+
build_stats_native_build_time
17331733
when 'runtime-compilable-methods'
1734-
build_stats_native_runtime_compilable_methods(*args)
1734+
build_stats_native_runtime_compilable_methods
17351735
else
17361736
raise ArgumentError, attribute
17371737
end
@@ -1743,25 +1743,21 @@ def build_stats(attribute, *args)
17431743
end
17441744
end
17451745

1746-
private def build_stats_native_binary_size(*args)
1746+
private def build_stats_native_binary_size
17471747
truffleruby_native!
17481748
File.size(language_lib_path) / 1024.0 / 1024.0
17491749
end
17501750

1751-
private def build_stats_native_build_time(*args)
1752-
log = File.read('aot-build.log')
1753-
unless log =~ /\[librubyvm:\d+\] Finished generating 'librubyvm' in (\d+)m (\d+)s\./
1754-
raise 'Could not find line with build time for librubyvm'
1755-
end
1756-
Integer($1) * 60 + Integer($2)
1751+
private def build_stats_native_build_time
1752+
require 'json'
1753+
data = JSON.load(File.read('native-image-build-rubyvm.json'))
1754+
data.fetch('resource_usage').fetch('total_secs')
17571755
end
17581756

1759-
private def build_stats_native_runtime_compilable_methods(*args)
1760-
log = File.read('aot-build.log')
1761-
unless log =~ /\[librubyvm:\d+\]\s*(?<method_count>[\d,]+)\s*runtime compiled methods/
1762-
raise 'Could not find line with runtime methods for librubyvm'
1763-
end
1764-
Integer($~[:method_count].gsub(',', ''))
1757+
private def build_stats_native_runtime_compilable_methods
1758+
require 'json'
1759+
data = JSON.load(File.read('native-image-build-rubyvm.json'))
1760+
data.fetch('image_details').fetch('runtime_compiled_methods').fetch('count')
17651761
end
17661762

17671763
def metrics(command, *args)

0 commit comments

Comments
 (0)