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: dd623ed0ed11
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7977908cad95
Choose a head ref
  • 6 commits
  • 1 file changed
  • 1 contributor

Commits on May 24, 2016

  1. Copy the full SHA
    2495bbd View commit details
  2. Copy the full SHA
    e17e20f View commit details
  3. Copy the full SHA
    2ef6955 View commit details
  4. Copy the full SHA
    b96a36a View commit details
  5. Copy the full SHA
    5c0b6ca View commit details
  6. Copy the full SHA
    7977908 View commit details
Showing with 32 additions and 114 deletions.
  1. +32 −114 tool/jt.rb
146 changes: 32 additions & 114 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -133,6 +133,14 @@ def self.find_jruby_bin_dir
end
end

def self.find_gem(name)
["#{JRUBY_DIR}/lib/ruby/gems/shared/gems", JRUBY_DIR, "#{JRUBY_DIR}/.."].each do |dir|
found = Dir.glob("#{dir}/#{name}*").first
return found if found
end
raise "Can't find the #{name} gem - gem install it in this repository, or put it in the repository directory or its parent"
end

def self.git_branch
@git_branch ||= `GIT_DIR="#{JRUBY_DIR}/.git" git rev-parse --abbrev-ref HEAD`.strip
end
@@ -187,22 +195,6 @@ def self.ensure_igv_running
end
end

def self.find_bench
bench_locations = [
ENV['BENCH_DIR'],
'bench9000',
'../bench9000'
].compact.map { |path| File.expand_path(path, JRUBY_DIR) }

not_found = -> {
raise "couldn't find bench9000 - clone it from https://github.com/jruby/bench9000.git into the JRuby repository or parent directory"
}

bench_locations.find(not_found) do |location|
Dir.exist?(location)
end
end

def self.jruby_version
File.read("#{JRUBY_DIR}/VERSION").strip
end
@@ -309,7 +301,6 @@ def help
puts ' --server run an instrumentation server on port 8080'
puts ' --igv make sure IGV is running and dump Graal graphs after partial escape (implies --graal)'
puts ' --full show all phases, not just up to the Truffle partial escape'
puts ' --bips run with benchmark-ips on the load path (implies --graal)'
puts ' --jdebug run a JDWP debug server on #{JDEBUG_PORT}'
puts ' --jexception[s] print java exceptions'
puts 'jt e 14 + 2 evaluate an expression'
@@ -331,19 +322,14 @@ def help
puts 'jt tag all spec/ruby/language tag all specs in this file, without running them'
puts 'jt untag spec/ruby/language untag passing specs in this directory'
puts 'jt untag spec/ruby/language/while_spec.rb untag passing specs in this file'
puts 'jt bench debug [options] [vm-args] benchmark run a single benchmark with options for compiler debugging'
puts ' --igv make sure IGV is running and dump Graal graphs after partial escape (implies --graal)'
puts ' --full show all phases, not just up to the Truffle partial escape'
puts ' --ruby-backtrace print a Ruby backtrace on any compilation failures'
puts 'jt bench reference [benchmarks] run a set of benchmarks and record a reference point'
puts 'jt bench compare [benchmarks] run a set of benchmarks and compare against a reference point'
puts ' benchmarks can be any benchmarks or group of benchmarks supported'
puts ' by bench9000, eg all, classic, chunky, 3, 5, 10, 15 - default is 5'
puts 'jt metrics [--score name] alloc ... how much memory is allocated running a program (use -X-T to test normal JRuby on this metric and others)'
puts ' --score name report results as scores'
puts 'jt metrics ... minheap ... what is the smallest heap you can use to run an application'
puts 'jt metrics ... time ... how long does it take to run a command, broken down into different phases'
puts 'jt metrics alloc ... how much memory is allocated running a program (use -X-T to test normal JRuby on this metric and others)'
puts 'jt metrics minheap ... what is the smallest heap you can use to run an application'
puts 'jt metrics time ... how long does it take to run a command, broken down into different phases'
puts 'jt tarball build the and test the distribution tarball'
puts 'jt benchmark args... run benchmark-interface (implies --graal)'
puts ' note that to run most MRI benchmarks, you should translate them first with normal Ruby and cache the result, such as'
puts ' benchmark bench/mri/bm_vm1_not.rb --cache'
puts ' jt benchmark bench/mri/bm_vm1_not.rb --use-cache'
puts
puts 'you can also put build or rebuild in front of any command'
puts
@@ -406,8 +392,7 @@ def run(*args)

{
'--asm' => '--graal',
'--igv' => '--graal',
'--bips' => '--graal'
'--igv' => '--graal'
}.each_pair do |arg, dep|
args.unshift dep if args.include?(arg)
end
@@ -430,13 +415,6 @@ def run(*args)
jruby_args += %w[-J-XX:+UnlockDiagnosticVMOptions -J-XX:CompileCommand=print,*::callRoot]
end

if args.delete('--bips')
bips_version = '2.6.1'
bips = "#{JRUBY_DIR}/lib/ruby/gems/shared/gems/benchmark-ips-#{bips_version}/lib"
sh 'bin/jruby', 'bin/gem', 'install', 'benchmark-ips', '-v', bips_version unless Dir.exist?(bips)
jruby_args << "-I#{bips}"
end

if args.delete('--jdebug')
jruby_args << JDEBUG
end
@@ -691,77 +669,22 @@ def untag(path, *args)
test_specs('untag', path, *args)
end

def bench(command, *args)
bench_dir = Utilities.find_bench
env_vars = {
"JRUBY_DEV_DIR" => JRUBY_DIR,
"GRAAL_BIN" => Utilities.find_graal,
}
bench_args = ["#{bench_dir}/bin/bench9000"]
case command
when 'debug'
vm_args = ['-G:+TraceTruffleCompilation', '-G:+DumpOnError']
if args.delete '--igv'
warn "warning: --igv might not work on master - if it does not, use truffle-head instead which builds against latest graal" if Utilities.git_branch == 'master'
Utilities.ensure_igv_running

if args.delete('--full')
vm_args.push '-G:Dump=Truffle'
else
vm_args.push '-G:Dump=TrufflePartialEscape'
end
end
if args.delete '--ruby-backtrace'
vm_args.push '-G:+TruffleCompilationExceptionsAreThrown'
else
vm_args.push '-G:+TruffleCompilationExceptionsAreFatal'
end
remaining_args = []
args.each do |arg|
if arg.start_with? '-'
vm_args.push arg
else
remaining_args.push arg
end
end
env_vars["JRUBY_OPTS"] = vm_args.map{ |a| '-J' + a }.join(' ')
bench_args += ['score', '--config', "#{bench_dir}/benchmarks/default.config.rb", 'jruby-dev-truffle-graal', '--show-commands', '--show-samples']
raise 'specify a single benchmark for run - eg classic-fannkuch-redux' if remaining_args.size != 1
args = remaining_args
when 'reference'
bench_args += ['reference', '--config', "#{bench_dir}/benchmarks/default.config.rb", 'jruby-dev-truffle-graal', '--show-commands']
args << "5" if args.empty?
when 'compare'
bench_args += ['compare-reference', '--config', "#{bench_dir}/benchmarks/default.config.rb", 'jruby-dev-truffle-graal']
args << "5" if args.empty?
else
raise ArgumentError, command
end
raw_sh env_vars, "ruby", *bench_args, *args
end

def metrics(command, *args)
trap(:INT) { puts; exit }
args = args.dup
if args.first == '--score'
args.shift
score_name = args.shift
else
score_name = nil
end
case command
when 'alloc'
metrics_alloc score_name, *args
metrics_alloc *args
when 'minheap'
metrics_minheap score_name, *args
metrics_minheap *args
when 'time'
metrics_time score_name, *args
metrics_time *args
else
raise ArgumentError, command
end
end

def metrics_alloc(score_name, *args)
def metrics_alloc(*args)
samples = []
METRICS_REPS.times do
log '.', 'sampling'
@@ -773,11 +696,7 @@ def metrics_alloc(score_name, *args)
end
log "\n", nil
mean = samples.inject(:+) / samples.size
if score_name
puts "alloc-#{score_name}: #{mean}"
else
puts "#{human_size(mean)}, max #{human_size(samples.max)}"
end
puts "#{human_size(mean)}, max #{human_size(samples.max)}"
end

def memory_allocated(trace)
@@ -796,7 +715,7 @@ def memory_allocated(trace)
allocated
end

def metrics_minheap(score_name, *args)
def metrics_minheap(*args)
heap = 10
log '>', "Trying #{heap} MB"
until can_run_in_heap(heap, *args)
@@ -821,18 +740,14 @@ def metrics_minheap(score_name, *args)
end
end
log "\n", nil
if score_name
puts "minheap-#{score_name}: #{heap*1024*1024}"
else
puts "#{heap} MB"
end
puts "#{heap} MB"
end

def can_run_in_heap(heap, *command)
run("-J-Xmx#{heap}M", *command, {err: '/dev/null', out: '/dev/null'}, :continue_on_failure, :no_print_cmd)
end

def metrics_time(score_name, *args)
def metrics_time(*args)
samples = []
METRICS_REPS.times do
log '.', 'sampling'
@@ -848,11 +763,7 @@ def metrics_time(score_name, *args)
samples[0].each_key do |region|
region_samples = samples.map { |s| s[region] }
mean = region_samples.inject(:+) / samples.size
if score_name
puts "time-#{region.strip}-#{score_name}: #{(mean*1000).round}"
else
puts "#{region} #{mean.round(2)} s"
end
puts "#{region} #{mean.round(2)} s"
end
end

@@ -915,6 +826,13 @@ def log(tty_message, full_message)
end
end

def benchmark(*args)
run '--graal',
'-I', "#{Utilities.find_gem('deep-bench')}/lib",
'-I', "#{Utilities.find_gem('benchmark-ips')}/lib",
"#{Utilities.find_gem('benchmark-interface')}/bin/benchmark", *args
end

def check_ambiguous_arguments
ENV.delete "JRUBY_ECLIPSE" # never run from the Eclipse launcher here
clean