Skip to content

Commit b2cec7c

Browse files
committed
[GR-45890] Use G1 by default on Native EE on Linux
PullRequest: truffleruby/3939
2 parents f5c5c19 + 41c2f89 commit b2cec7c

File tree

15 files changed

+57
-21
lines changed

15 files changed

+57
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
New features:
44

55
* Updated to Ruby 3.2.2 (#3039, @eregon, @andrykonchin).
6+
* TruffleRuby Native on Oracle GraalVM on Linux now uses the G1 garbage collector which is much faster.
67

78
Bug fixes:
89

ci.jsonnet

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ local part_definitions = {
204204
HOST_VM_CONFIG: "graal-enterprise",
205205
},
206206
},
207+
native_ee_aux: {
208+
mx_env:: "native-ee-aux",
209+
},
207210
host_inlining_log: {
208211
# Same as in mx.truffleruby/native-host-inlining
209212
mx_options+:: [
@@ -551,6 +554,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
551554
"ruby-test-svm-ce-darwin-aarch64-new": $.platform.darwin_aarch64 + $.jdk.new + $.env.native + gate + native_tests,
552555
"ruby-test-svm-ee-linux-amd64": $.platform.linux + $.jdk.lts + $.env.native_ee + $.env.gdb_svm + gate + native_tests + $.env.host_inlining_log + { timelimit: "01:30:00" },
553556
"ruby-test-svm-ee-darwin-aarch64": $.platform.darwin_aarch64 + $.jdk.lts + $.env.native_ee + gate + native_tests,
557+
"ruby-test-svm-ee-aux-linux-amd64": $.platform.linux + $.jdk.lts + $.env.native_ee_aux + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
554558
},
555559

556560
local other_rubies = {

mx.truffleruby/env_files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Here is how the various env files relate to each other:
88
* `jvm-ee`: + Oracle GraalVM Compiler + `Truffle enterprise`
99
* `jvm-ee-ntl`: + native toolchain launchers
1010
* `jvm-ee-libgraal`: + libgraal
11-
* `native-ee`: + librubyvm + `Truffle Macro Enterprise`
12-
* `native-ee-g1`: + Native Image G1
11+
* `native-ee`: + librubyvm + `Truffle Macro Enterprise` + Native Image G1
12+
* `native-ee-aux`: + `AuxiliaryEngineCache`, - Native Image G1 (currently incompatible)
1313
* `jvm-gu`: + Graal Updater
1414
* `jvm-js`: + Graal.js
1515
* `jvm-py`: + GraalPython

mx.truffleruby/jvm-ee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
GRAALVM_SKIP_ARCHIVE=true
2-
DYNAMIC_IMPORTS=/tools,/graal-enterprise
2+
DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise

mx.truffleruby/jvm-ee-libgraal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
GRAALVM_SKIP_ARCHIVE=true
2-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise
2+
DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-enterprise
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,LibGraal Enterprise
44
NATIVE_IMAGES=suite:sulong,lib:jvmcicompiler

mx.truffleruby/jvm-ee-ntl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
GRAALVM_SKIP_ARCHIVE=true
2-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise
2+
DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-enterprise
33
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise
44
NATIVE_IMAGES=suite:sulong

mx.truffleruby/mx_truffleruby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def verify_ci(args):
306306
],
307307
build_args_enterprise=[
308308
'-J-Xmx7g', # Set Xmx to use a reliable amount of memory
309-
],
309+
] + (['--gc=G1', '-H:-ProtectionKeys'] if (mx.get_os() == 'linux' and 'NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE' not in os.environ) else []), # G1 is only supported on linux currently
310310
language='ruby',
311311
option_vars=[
312312
'RUBYOPT',

mx.truffleruby/native-ee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GRAALVM_SKIP_ARCHIVE=true
2-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise
3-
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise
2+
DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
3+
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise,suite:substratevm-enterprise-gcs
44
NATIVE_IMAGES=suite:sulong,lib:rubyvm
5-
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:+AuxiliaryEngineCache rubyvm:-H:ReservedAuxiliaryImageBytes=1073741824
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json
66
# To also create the standalone
7-
INSTALLABLES=TruffleRuby
7+
INSTALLABLES=TruffleRuby
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
GRAALVM_SKIP_ARCHIVE=true
2-
DYNAMIC_IMPORTS=/tools,/graal-enterprise,/substratevm-enterprise,substratevm-enterprise-gcs
3-
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise,SubstrateVM Enterprise GC
2+
DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-enterprise
3+
COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise
44
NATIVE_IMAGES=suite:sulong,lib:rubyvm
5-
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:+UseG1GC
5+
EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:+AuxiliaryEngineCache rubyvm:-H:ReservedAuxiliaryImageBytes=1073741824
6+
NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE=true
67
# To also create the standalone
78
INSTALLABLES=TruffleRuby

spec/tags/core/gc/count_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
slow:GC.count increases as collections are run
2+
native-g1:GC.count increases as collections are run

spec/tags/core/gc/stat_tags.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
slow:GC.stat increases count after GC is run
22
slow:GC.stat increases major_gc_count after GC is run
33
fails:GC.stat raises an error if an unknown key is given
4+
native-g1:GC.stat increases count after GC is run
5+
native-g1:GC.stat increases major_gc_count after GC is run

spec/tags/optional/capi/gc_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ slow:CApiGCSpecs rb_gc increases gc count
22
fails:CApiGCSpecs rb_gc_adjust_memory_usage adjusts the amount of registered external memory
33
slow:CApiGCSpecs rb_gc_register_address keeps the value alive even if the value is assigned after rb_gc_register_address() is called
44
slow:CApiGCSpecs rb_global_variable keeps the value alive even if the value is assigned after rb_global_variable() is called
5+
native-g1:CApiGCSpecs rb_gc increases gc count

spec/truffleruby.mspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ class MSpecScript
118118

119119
if defined?(::TruffleRuby)
120120
if TruffleRuby.native?
121-
excludes << 'aot'
121+
excludes << 'native'
122+
if GC.heap_stats.values.none?(Hash)
123+
excludes << 'native-g1'
124+
end
122125
else
123126
excludes << 'jvm'
124127
end

test/truffle/compiler/engine-caching.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ source test/truffle/common.sh.inc
55
ruby_version=$(jt ruby -v)
66

77
if [[ ! $ruby_version =~ "Oracle GraalVM Native" ]]; then
8-
echo Oracle GraalVM Native not detected, no tests to run.
8+
echo Oracle GraalVM Native not detected, skipping test
99
exit 0
1010
fi
1111

12+
set +x
13+
output=$(jt ruby --experimental-options --engine.CacheLoad=does-not-exist.image -e0 2>&1 || true)
14+
15+
if [[ $output =~ "AuxiliaryEngineCache at image build time" ]]; then
16+
echo Oracle GraalVM Native without AuxiliaryEngineCache, skipping test
17+
exit 0
18+
fi
19+
set -x
20+
1221
# Store the image
1322
jt ruby --experimental-options --engine.TraceCache --engine.CacheCompile=executed --engine.CacheStore=core.image test/truffle/compiler/engine_caching/engine_caching.rb
1423

tool/jt.rb

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,8 +1082,21 @@ def rebuild(*options)
10821082
vm_args << "--core-load-path=#{TRUFFLERUBY_DIR}/src/main/ruby/truffleruby"
10831083
end
10841084

1085-
if ci? and truffleruby_jvm?
1086-
vm_args << '--vm.Xlog:os+thread=off' # GR-23507: prevent thread warnings on stdout to break specs/tests
1085+
if ci?
1086+
# GR-23507: prevent thread warnings on stdout to break specs/tests/programs using execve().
1087+
# The problem happens if one thread is calling execve() and the other about the same time is calling pthread_create().
1088+
# In such case, pthread_create() can return EAGAIN "just because there is a concurrent execve()".
1089+
# See https://bugs.openjdk.org/browse/JDK-8268605?focusedCommentId=14473665#comment-14473665
1090+
# To solve this we move VM warnings to stderr instead of stdout to avoid breaking specs, and logging should be on stderr anyway.
1091+
# '--vm.Xlog:os+thread=off' '--vm.Xlog:gc+task=off' would also be a possibility, but unfortunately
1092+
# these flags don't seem to combine with moving all warnings to stderr so we have to pick one approach.
1093+
# Example warnings:
1094+
# JVM:
1095+
# [11.028s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 2048k, guardsize: 0k, detached.
1096+
# SVM with G1:
1097+
# [0.094s][warning][os,thread] Failed to start thread "GC Thread#1" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached.
1098+
# [0.094s][error ][gc,task ] GC(0) Failed to create worker thread
1099+
vm_args << '--vm.Xlog:all=warning:stderr'
10871100
end
10881101

10891102
[vm_args, ruby_args + args, options]
@@ -1630,20 +1643,21 @@ def mspec(*args)
16301643
private def test_specs(command, *args)
16311644
env_vars = {}
16321645
options = []
1646+
tag = ENV['TAG'] || 'fails'
16331647

16341648
case command
16351649
when 'run'
16361650
options += %w[--excl-tag fails]
16371651
when 'tag'
1638-
options += %w[--add fails --fail --excl-tag fails]
1652+
options += %W[--add #{tag} --fail --excl-tag fails]
16391653
when 'untag'
1640-
options += %w[--del fails --pass]
1654+
options += %W[--del #{tag} --pass]
16411655
command = 'tag'
16421656
when 'purge'
16431657
options += %w[--purge]
16441658
command = 'tag'
16451659
when 'tag_all'
1646-
options += %w[--unguarded --all --dry-run --add fails]
1660+
options += %W[--unguarded --all --dry-run --add #{tag}]
16471661
command = 'tag'
16481662
else
16491663
raise command
@@ -2234,7 +2248,7 @@ def graph(*args)
22342248
# See org.graalvm.compiler.debug.StandardPathUtilitiesProvider#sanitizeFileName
22352249
method_glob_pattern = method.gsub(/[ \/\p{Cntrl}]/, '_')
22362250
if truffleruby_native?
2237-
method_glob_pattern = "Isolated:_#{method_glob_pattern}"
2251+
method_glob_pattern = "{Isolated:_,}#{method_glob_pattern}"
22382252
end
22392253

22402254
dumps = Dir.glob('graal_dumps/*').select { |path| File.directory?(path) }.sort.last

0 commit comments

Comments
 (0)