Skip to content

Commit

Permalink
Merge branch 'master' into 2615-process-euid-should-accept-string
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtban committed May 11, 2022
2 parents 92636d8 + 0d7b24d commit 047e7c2
Show file tree
Hide file tree
Showing 47 changed files with 329 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.6, 2.7, '3.0']
ruby: [2.7, '3.0', 3.1]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Bug fixes:
* Fix capacity computation for huge `Hash` (#2635, @eregon).
* Fix aliased methods to return the correct owner when method is from a superclass (@bjfish).
* Fix `String#[Regexp, Integer]` when the capture group exists but is not matched (@eregon).
* Fix `File.open` mode string parsing when binary option is the third character (@bjfish).
* Fix `rb_scan_args_kw` macro to avoid shadowing variables (#2649, @aardvark179).

Compatibility:

Expand All @@ -22,6 +24,8 @@ Compatibility:
* Implement `rb_gc_mark_maybe` and `rb_global_variable` to ensure `VALUE` stay live in C extensions (@aardvark179).
* Implement `rb_imemo_tmpbuf` allocation for `ripper` (@aardvark179).
* `Process.euid=` should accept String (#2615, @ngtban).
* Implement `inherit` argument for `Module#class_variables` (#2653, @bjfish).
* Fix `Float#/` when dividing by `Rational` (@bjfish).

Performance:

Expand Down
4 changes: 2 additions & 2 deletions bench/benchmark-interface/examples/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

start = Time.now
start = BenchmarkInterface.get_time

benchmark do
1/0 if Time.now - start > 3
1/0 if BenchmarkInterface.get_time - start > 3
end
9 changes: 7 additions & 2 deletions bench/benchmark-interface/lib/benchmark-interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# GNU Lesser General Public License version 2.1.

require 'benchmark-interface/version'
require 'benchmark-interface/timing'
require 'benchmark-interface/benchmark'
require 'benchmark-interface/benchmark-api'
require 'benchmark-interface/benchmark-set'
require 'benchmark-interface/frontends/mri'
require 'benchmark-interface/backends/simple'
Expand All @@ -21,24 +23,27 @@
require 'benchmark-interface/run'

module BenchmarkInterface
extend Timing

def self.benchmark(name=nil, &block)
BenchmarkInterface::BenchmarkSet.current.register name, block
end

def self.run_n_iterations(iterations)
i = 0
while i < iterations
yield
result = yield
i += 1
end
result
end
end

def benchmark(name=nil, &block)
BenchmarkInterface.benchmark name, &block
end

if $PROGRAM_NAME.split('/').last != 'benchmark'
if File.basename($PROGRAM_NAME) != 'benchmark'
set = BenchmarkInterface::BenchmarkSet.new
backend = BenchmarkInterface::Backends::Bips

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,11 @@
module BenchmarkInterface
module Backends
module Simple

extend BenchmarkInterface::Timing

INITIAL_ITERATIONS = 1
MAX_ITERATIONS = 2147483647

# Accomodates Rubinius

if defined?(Process::CLOCK_MONOTONIC)
def self.get_time
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
else
def self.get_time
Time.now
end
end

def self.run(benchmark_set, names, options)
full_time = options['--time']
freq = options['--freq']
Expand All @@ -42,8 +31,9 @@ def self.run(benchmark_set, names, options)

while get_time - start_time < full_time
start_round_time = get_time
BenchmarkInterface.run_n_iterations(iterations, &block)
result = BenchmarkInterface.run_n_iterations(iterations, &block)
round_time = get_time - start_round_time
benchmark.verify!(result)

# If the round time was very low and so very imprecise then we may
# get a wild number of iterations next time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module BenchmarkInterface
module Backends
module Stable
extend BenchmarkInterface::Timing

def self.run(benchmark_set, names, options)
full_time = options['--time']
Expand All @@ -22,16 +23,16 @@ def self.run(benchmark_set, names, options)
puts benchmark.name
block = benchmark.block

start_time = Time.now
start_time = get_time

while Time.now - start_time < full_time
start_round_time = Time.now
while get_time - start_time < full_time
start_round_time = get_time
block.call
round_time = Time.now - start_round_time
round_time = get_time - start_round_time

ips = 1 / round_time
puts 1 if print_iterations
puts Time.now - start_time if elapsed
puts get_time - start_time if elapsed
puts ips * inner_iterations
end
end
Expand Down
21 changes: 21 additions & 0 deletions bench/benchmark-interface/lib/benchmark-interface/benchmark-api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2022 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 2.0, or
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

module BenchmarkInterface
class BenchmarkAPI
attr_reader :benchmark

def initialize(benchmark)
@benchmark = benchmark
end

def verify(&block)
@benchmark.verify_block = block
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def load_mri_benchmarks(path, options)

def register(name, code)
name = implicit_name unless name
@benchmarks.push Benchmark.new(name, code)
benchmark = Benchmark.new(name, code)
@benchmarks.push benchmark
BenchmarkInterface::BenchmarkAPI.new(benchmark)
end

def implicit_name
Expand Down
24 changes: 19 additions & 5 deletions bench/benchmark-interface/lib/benchmark-interface/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,45 @@ module BenchmarkInterface
class Benchmark

attr_reader :name, :block

attr_writer :verify_block

def initialize(name, block)
@name = name
@block = block
end

def verify!(result)
if @verify_block
check = @verify_block.call(result)
unless check
raise "Benchmark #{@name} did not return the correct value, " \
"the verify block returned #{check.inspect} and the result was:\n#{result.inspect}"
end
end
end

def remove_line_numbers
@name = @name.split(':')[0...-1].join(':') if @name.include? ':'
end

def time_block(desired_time)
iterations = 1
while true
start = Time.now
start = BenchmarkInterface.get_time
if block.arity == 1
block.call iterations
result = block.call iterations
else
BenchmarkInterface.run_n_iterations(iterations, &block)
result = BenchmarkInterface.run_n_iterations(iterations, &block)
end
time = BenchmarkInterface.get_time - start

verify!(result)

time = Time.now - start
return [time, iterations] if time >= desired_time
iterations *= 2
end
end
private :time_block

def basic_iteration_time
time, iterations = time_block(0.1)
Expand Down
22 changes: 22 additions & 0 deletions bench/benchmark-interface/lib/benchmark-interface/timing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2022 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 2.0, or
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

module BenchmarkInterface
module Timing
if defined?(Process::CLOCK_MONOTONIC)
def get_time
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
else
# Accomodates Rubinius
def get_time
Time.now
end
end
end
end
4 changes: 3 additions & 1 deletion bench/liquid/liquid-bibs-render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
benchmark do
result = template.render!(data)
dev_null.write result
raise StandardError, "Incorrect rendering result" unless result == expected_result
result
end.verify do |result|
result == expected_result
end
18 changes: 4 additions & 14 deletions ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# https://github.com/google/jsonnet/releases and compiled.

# CONFIGURATION
local overlay = "ffb092a26e86b0b4c2ac33bdbc329d938b527942";
local overlay = "52900f1ecd0b7b23e0bbb74e7552886e6ec29df3";

# For debugging: generated builds will be restricted to those listed in
# the array. No restriction is applied when it is empty.
Expand All @@ -34,6 +34,8 @@ local part_definitions = {

use: {
common: {
python_version: "3", # To use the correct virtualenv

environment+: {
path+:: [],
TRUFFLERUBY_CI: "true",
Expand Down Expand Up @@ -676,19 +678,6 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
"ruby-benchmarks-other-svm-graal-enterprise-multi-tier": shared + svm_other + svm_configurations["svm-graal-enterprise"] + $.use.multi_tier,
} +

{
local shared = $.platform.linux + $.jdk.v11 + $.use.common + $.use.gem_test_pack +
$.benchmark.runner + $.benchmark.server +
{ timelimit: "00:30:00" },

"ruby-benchmarks-server-mri": shared + other_rubies.mri,
"ruby-benchmarks-server-jruby": shared + other_rubies.jruby,
"ruby-benchmarks-server-graal-core": shared + graal_configurations["graal-core"] + $.use.no_multi_tier,
"ruby-benchmarks-server-graal-core-multi-tier": shared + graal_configurations["graal-core"] + $.use.multi_tier,
"ruby-benchmarks-server-graal-enterprise": shared + graal_configurations["graal-enterprise"] + $.use.no_multi_tier,
"ruby-benchmarks-server-graal-enterprise-multi-tier": shared + graal_configurations["graal-enterprise"] + $.use.multi_tier,
} +

{
"ruby-metrics-truffle":
$.platform.linux + $.jdk.v11 + $.use.common + $.env.jvm + $.use.build +
Expand Down Expand Up @@ -735,6 +724,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
};

{
part_definitions:: part_definitions,
specVersion: "3",
overlay: overlay,
builds: composition_environment.builds,
Expand Down
24 changes: 14 additions & 10 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,18 @@
],

"deps": {
"COMMENT.common": [
"pip:isort is a dependency of pip:pylint. The explicit dependency on the pip package works around",
"https://bugzilla.redhat.com/show_bug.cgi?id=1710221 on older Redhat-based systems, and doesn't",
"hurt on others."
],
"common": {
"timelimit": "30:00",
"environment": {
"MX_PYTHON": "python3"
"MX_PYTHON": "python3.8"
},
"packages": {
"pip:isort": "==4.3.19",
"pip:logilab-common": "==1.4.4",
"pip:pylint": "==1.9.3",
"python3": "==3.8.10",
"pip:pylint": "==2.4.4",
"pip:lazy-object-proxy": "==1.6.0",
"pip:ninja_syntax": "==1.7.2"
}
},
"python_version": "3"
},

"linux": {
Expand Down Expand Up @@ -80,6 +75,15 @@
},
"environment": {
"ECLIPSE_EXE": "$ECLIPSE/eclipse"
},

"COMMENT.eclipse_org": [
"Coordinates for downloading same version as above directly from eclipse.org (used by GitHub actions).",
"Template URL: https://archive.eclipse.org/eclipse/downloads/drops4/R-<eclipse_org.version>-<eclipse_org.timestamp>/eclipse-SDK-<eclipse_org.version>-linux-gtk-x86_64.tar.gz"
],
"eclipse_org": {
"version": "4.14",
"timestamp": "201912100610"
}
},
"jdt": {
Expand Down
2 changes: 1 addition & 1 deletion lib/cext/ABI_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3
4
Loading

0 comments on commit 047e7c2

Please sign in to comment.