Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 70b51aa3a710
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a540afcbca8a
Choose a head ref
  • 6 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 5, 2016

  1. Copy the full SHA
    1333c55 View commit details
  2. Copy the full SHA
    58271cf View commit details
  3. Copy the full SHA
    7fe0c9c View commit details
  4. Copy the full SHA
    3fffafb View commit details
  5. Copy the full SHA
    38c6ef7 View commit details
  6. Copy the full SHA
    a540afc View commit details
Showing with 149 additions and 14 deletions.
  1. +37 −2 ci.hocon
  2. +69 −1 mx.jruby/mx_jruby.py
  3. +20 −11 tool/jt.rb
  4. +23 −0 tool/truffle/post-process-results-json.rb
39 changes: 37 additions & 2 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -18,14 +18,22 @@ common: {
}

environment: {
CI: "true"
CI: "true",
JAVA_OPTS: -Xmx2G
}

setup: ${common-setup}

timelimit: "30:00"
}

no-graal: {
environment: {
HOST_VM: server,
HOST_VM_CONFIG: default
}
}

graal-core: {
setup: ${common-setup} [
[mkdir, graal-workspace],
@@ -39,7 +47,9 @@ graal-core: {
]

environment: {
GRAAL_BIN: graal-workspace/jvmci/jdk1.8.0_60/product/bin/java
GRAAL_BIN: graal-workspace/jvmci/jdk1.8.0_60/product/bin/java,
HOST_VM: server,
HOST_VM_CONFIG: graal-core
}
}

@@ -54,6 +64,31 @@ graalvm: {

environment: {
GRAAL_BIN: "$GRAALVM_DIR/bin/java"
HOST_VM: server,
HOST_VM_CONFIG: graal-enterprise
}
}

jruby-noindy: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: noindy,
JRUBY_OPTS: '-X-T -Xcompile.invokedynamic=false'
}
}

jruby-indy: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: indy,
JRUBY_OPTS: '-X-T -Xcompile.invokedynamic=true'
}
}

jruby-truffle: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: truffle,
}
}

70 changes: 69 additions & 1 deletion mx.jruby/mx_jruby.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import mx
import os
import subprocess
import shutil
import json

import mx
import mx_benchmark

_suite = mx.suite('jruby')

def jt(args, suite=None, nonZeroIsFatal=True, out=None, err=None, timeout=None, env=None, cwd=None):
rubyDir = _suite.dir
jt = os.path.join(rubyDir, 'tool', 'jt.rb')
mx.run(['ruby', jt] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, timeout=timeout, env=env, cwd=cwd)

class MavenProject(mx.Project):
def __init__(self, suite, name, deps, workingSets, theLicense, **args):
mx.Project.__init__(self, suite, name, "", [], deps, workingSets, _suite.dir, theLicense)
@@ -108,3 +116,63 @@ def clean(self, forBuild=False):
return
rubyDir = _suite.dir
mx.run_maven(['clean'], nonZeroIsFatal=False, cwd=rubyDir)

class RubyBenchmarkSuite(mx_benchmark.BenchmarkSuite):
def group(self):
return 'Graal'

def subgroup(self):
return 'jrubytruffle'

def vmArgs(self, bmSuiteArgs):
return mx_benchmark.splitArgs(bmSuiteArgs, bmSuiteArgs)[0]

def runArgs(self, bmSuiteArgs):
return mx_benchmark.splitArgs(bmSuiteArgs, bmSuiteArgs)[1]

def run(self, benchmarks, bmSuiteArgs):
def fixUpResult(result):
result.update({
'host-vm': os.environ['HOST_VM'],
'host-vm-config': os.environ['HOST_VM_CONFIG'],
'guest-vm': os.environ['GUEST_VM'],
'guest-vm-config': os.environ['GUEST_VM_CONFIG']
})
return result

return [fixUpResult(self.runBenchmark(b, bmSuiteArgs)) for b in benchmarks or self.benchmarks()]

def runBenchmark(self, benchmark, bmSuiteArgs):
raise NotImplementedError()

allocation_benchmarks = {
'hello': ['-e', "puts 'hello'"]
}

class AllocationBenchmarkSuite(RubyBenchmarkSuite):
def name(self):
return 'allocation'

def benchmarks(self):
return allocation_benchmarks.keys()

def runBenchmark(self, benchmark, bmSuiteArgs):
out = mx.OutputCapture()

options = []

jt(['metrics', 'alloc', '--json'] + allocation_benchmarks[benchmark] + bmSuiteArgs, out=out)

data = json.loads(out.data)

result = {
'benchmark': benchmark,
'metric.name': 'memory',
'metric.value': data['median'],
'metric.unit': 'B',
'extra.metric.error-num': data['error']
}

return result

mx_benchmark.add_bm_suite(AllocationBenchmarkSuite())
31 changes: 20 additions & 11 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -414,11 +414,16 @@ def rebuild

def run(*args)
env_vars = args.first.is_a?(Hash) ? args.shift : {}

jruby_args = [
'-X+T',
"-Xtruffle.core.load_path=#{JRUBY_DIR}/truffle/src/main/ruby",
'-Xtruffle.graal.warn_unless=false'
]

if ENV['JRUBY_OPTS'] && ENV['JRUBY_OPTS'].include?('-X-T')
jruby_args.delete '-X+T'
end

{
'--asm' => '--graal',
@@ -725,20 +730,24 @@ def metrics_alloc(*args)
use_json = args.delete '--json'
samples = []
METRICS_REPS.times do
log '.', 'sampling'
log '.', "sampling\n"
r, w = IO.pipe
run '-Xtruffle.metrics.memory_used_on_exit=true', '-J-verbose:gc', *args, {err: w, out: w}, :no_print_cmd
w.close
samples.push memory_allocated(r.read)
r.close
end
log "\n", nil
mean = samples.inject(:+) / samples.size
error = samples.max - mean
range = samples.max - samples.min
error = range / 2
median = samples.min + error
if use_json
puts JSON.generate({mean: mean, error: error})
puts JSON.generate({
median: median,
error: error
})
else
puts "#{human_size(mean)} ± #{human_size(error)}"
puts "#{human_size(median)} ± #{human_size(error)}"
end
end

@@ -760,19 +769,19 @@ def memory_allocated(trace)

def metrics_minheap(*args)
heap = 10
log '>', "Trying #{heap} MB"
log '>', "Trying #{heap} MB\n"
until can_run_in_heap(heap, *args)
heap += 10
log '>', "Trying #{heap} MB"
log '>', "Trying #{heap} MB\n"
end
heap -= 9
heap = 1 if heap == 0
successful = 0
loop do
if successful > 0
log '?', "Verifying #{heap} MB"
log '?', "Verifying #{heap} MB\n"
else
log '+', "Trying #{heap} MB"
log '+', "Trying #{heap} MB\n"
end
if can_run_in_heap(heap, *args)
successful += 1
@@ -793,7 +802,7 @@ def can_run_in_heap(heap, *command)
def metrics_time(*args)
samples = []
METRICS_REPS.times do
log '.', 'sampling'
log '.', "sampling\n"
r, w = IO.pipe
start = Time.now
run '-Xtruffle.metrics.time=true', *args, {err: w, out: w}, :no_print_cmd
@@ -866,7 +875,7 @@ def log(tty_message, full_message)
if STDERR.tty?
STDERR.print tty_message unless tty_message.nil?
else
STDERR.puts full_message unless full_message.nil?
STDERR.print full_message unless full_message.nil?
end
end

23 changes: 23 additions & 0 deletions tool/truffle/post-process-results-json.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
# This code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require 'json'

result = JSON.parse(File.read(ARGV[0]))

# Remove extra commit information, as it comes from our shimmed mx suite and
# is therefore potentially wrong.

result['queries'].each do |q|
q.delete_if do |k, v|
k =~ /extra\.\w+\.commit.\w+/
end
end

File.write(ARGV[1], JSON.pretty_generate(result))