Age | Commit message (Collapse) | Author |
|
|
|
MonitorMixin::ConditionVariable#wait can be interrupted just after
Monitor#exit_for_cond. So implementation in C.
|
|
Delegate MonitorMixin#synchronize body to Monitor#synchronize.
It makes guarantee interrupt safe (because Monitor#synchronize is
written in C). I thought Ruby implementation is also safe, but I
got stuck failure <http://ci.rvm.jp/results/trunk_test@P895/2327639>
so that I introduce this fix to guarantee interrupt safe.
|
|
Recent monitor.rb has performance problem because of interrupt
handlers. 'Monitor#synchronize' is frequently used primitive
so the performance of this method is important.
This patch rewrite 'monitor.rb' with 'monitor.so' (C-extension)
and make it faster. See [Feature #16255] for details.
Monitor class objects are normal object which include MonitorMixin.
This patch introduce a Monitor class which is implemented on C
and MonitorMixin uses Monitor object as re-entrant (recursive)
Mutex. This technique improve performance because we don't need
to care atomicity and we don't need accesses to instance variables
any more on Monitor class.
Notes:
Merged-By: ko1 <ko1@atdot.net>
|
|
|
|
This constant isn't used, so lets remove it.
|
|
The global can go bad if the compactor runs, so we need to look up the
constant instead of caching it in a global.
|
|
https://github.com/flori/json/commit/0e99a9aac5
|
|
In where to convert Hash key to String for json, this patch will add shortcut for String/Symbol in Hash key.
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 65.000 i/100ms
Calculating -------------------------------------
json 659.576 (± 1.5%) i/s - 3.315k in 5.027127s
```
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 78.000 i/100ms
Calculating -------------------------------------
json 789.781 (± 2.7%) i/s - 3.978k in 5.041043s
```
```
require 'json'
require 'benchmark/ips'
obj = []
1000.times do |i|
obj << {
"id" => i,
:age => 42,
}
end
Benchmark.ips do |x|
x.report "json" do |iter|
count = 0
while count < iter
JSON.generate(obj)
count += 1
end
end
end
```
https://github.com/flori/json/commit/38c0f6dbe4
|
|
To convert Hash convert, this part was using following pseudo code
```
obj.keys.each do |key|
value = obj[key]
...
end
```
and `rb_funcall()` was called for `obj.keys`.
It might be slightly heavy to call the Ruby method.
This patch will iterate to convert Hash object about key/value using `rb_hash_foreach()` Ruby API instead of `rb_funcall()`.
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 55.000 i/100ms
Calculating -------------------------------------
json 558.501 (± 1.1%) i/s - 2.805k in 5.022986s
```
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 65.000 i/100ms
Calculating -------------------------------------
json 659.576 (± 1.5%) i/s - 3.315k in 5.027127s
```
```
require 'json'
require 'benchmark/ips'
obj = []
1000.times do |i|
obj << {
"id" => i,
:age => 42,
}
end
Benchmark.ips do |x|
x.report "json" do |iter|
count = 0
while count < iter
JSON.generate(obj)
count += 1
end
end
end
```
https://github.com/flori/json/commit/a73323dc5e
|
|
flori/json@c34d01ff6a18dac04a90b2e0f820cdb1d5c7e1b2 does not
consider US-ASCII compatible but non-UTF-8 encodings, and causes
an error in RDoc tests.
https://github.com/flori/json/commit/4f471bf590
|
|
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 129.000 i/100ms
Calculating -------------------------------------
json 1.300k (± 2.3%) i/s - 6.579k in 5.064656s
```
## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 189.000 i/100ms
Calculating -------------------------------------
json 1.964k (± 3.3%) i/s - 9.828k in 5.011237s
```
## Code
```
require 'json'
require 'benchmark/ips'
obj = []
1000.times do |i|
obj << {
"id" => i,
:age => 42,
}
end
Benchmark.ips do |x|
x.report "json" do |iter|
count = 0
while count < iter
JSON.generate(obj)
count += 1
end
end
end
```
https://github.com/flori/json/commit/c34d01ff6a
|
|
`rb_funcall` might be slightly heavy to call the Ruby method.
This patch will convert String encoding using `rb_str_encode()` instead of `rb_funcall()`.
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 78.000 i/100ms
Calculating -------------------------------------
json 789.781 (± 2.7%) i/s - 3.978k in 5.041043s
```
## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 129.000 i/100ms
Calculating -------------------------------------
json 1.300k (± 2.3%) i/s - 6.579k in 5.064656s
```
## Code
```
require 'json'
require 'benchmark/ips'
obj = []
1000.times do |i|
obj << {
"id" => i,
:age => 42,
}
end
Benchmark.ips do |x|
x.report "json" do |iter|
count = 0
while count < iter
JSON.generate(obj)
count += 1
end
end
end
```
https://github.com/flori/json/commit/9ae6d2969c
|
|
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 25.000 i/100ms
Calculating -------------------------------------
json 250.478 (± 4.8%) i/s - 1.250k in 5.002238s
```
## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
json 32.000 i/100ms
Calculating -------------------------------------
json 360.652 (± 3.6%) i/s - 1.824k in 5.064511s
```
## Test code
```
require 'json'
require 'benchmark/ips'
obj = []
1000.times do |i|
obj << {
:string => "x" * 100,
:utf8 => "あ" * 100
}
end
Benchmark.ips do |x|
x.report "json" do |iter|
count = 0
while count < iter
JSON.generate(obj)
count += 1
end
end
end
```
https://github.com/flori/json/commit/91a24ecac3
|
|
https://github.com/flori/json/commit/36a7ef6790
|
|
https://github.com/flori/json/commit/167ada8da7
|
|
To get rid of a bug of `onig_region_set` which takes `int`s
instead of `OnigPosition`s, set elements of `beg` and `end`
members directly, for the time being.
|
|
Notes:
Merged-By: kou <kou@clear-code.com>
|
|
|
|
This macro is used here before defined in ruby.h.
|
|
Cited from mount(8):
```
strictatime
Always update the file access time when reading from a
file. Without this option the filesystem may default to a
less strict update mode, where some access time updates
are skipped for performance reasons. This option could be
ignored if it is not supported by the filesystem.
```
|
|
Otherwise, requiring syslog results in:
cannot locate symbol "__android_log_print" referenced by "syslog.so"
|
|
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): prefer
`rb_gc_register_mark_object`, which is better for constant
objects, over `rb_gc_register_address` for global/static
variables which can be re-assigned at runtime. [Bug #16196]
|
|
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): register the static
variable to grab an internal object, before creating the object.
otherwise the just-created object could get collected during the
global variable list allocation. [Bug #16196]
|
|
Sync to ruby/bigdecimal@92356ba71c6bd325b0ab618c634a7aecf8cdc767
Notes:
Merged-By: mrkn <mrkn@ruby-lang.org>
|
|
to suppress a warning in OpenBSD.
```
ossl_ssl.c:938:31: warning: incompatible pointer types passing 'SSL_SESSION *(SSL *, unsigned char *, int, int *)' (aka 'struct ssl_session_st *(struct ssl_st *, unsigned char *, int, int *)') to parameter of type 'SSL_SESSION *(*)(struct ssl_st *, const unsigned char *, int, int *)' (aka 'struct ssl_session_st *(*)(struct ssl_st *, const unsigned char *, int, int *)') [-Wincompatible-pointer-types]
SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/ssl.h:738:20: note: passing argument to parameter 'get_session_cb' here
SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
^
1 warning generated.
```
|
|
|
|
Follow up of 5717e55e9a7790c938afa694a9bf558c0e54bb83.
Adding a header with newline broke linenos.
|
|
char is not always signed. In fact, it is unsigned in arm.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20191004T181708Z.log.html.gz
```
compiling parser.c
parser.rl: In function ‘unescape_unicode’:
parser.rl:50:5: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (b < 0) return UNI_REPLACEMENT_CHAR;
^
```
|
|
to parser.c.
|
|
There have been some direct changes in parser.c which is automatically
generated from parser.rl. This updates parser.rl to sync the changes:
* 91793b8967e0531bd1159a8ff0cc7e50739c7620
* 79ead821dd4880725c9c6bb9645b3fad71715c5b
* 80b5a0ff2a7709367178f29d4ebe1c54122b1c27
|
|
This reverts commits: 10d6a3aca7 8ba48c1b85 fba8627dc1 dd883de5ba
6c6a25feca 167e6b48f1 7cb96d41a5 3207979278 595b3c4fdd 1521f7cf89
c11c5e69ac cf33608203 3632a812c0 f56506be0d 86427a3219 .
The reason for the revert is that we observe ABA problem around
inline method cache. When a cache misshits, we search for a
method entry. And if the entry is identical to what was cached
before, we reuse the cache. But the commits we are reverting here
introduced situations where a method entry is freed, then the
identical memory region is used for another method entry. An
inline method cache cannot detect that ABA.
Here is a code that reproduce such situation:
```ruby
require 'prime'
class << Integer
alias org_sqrt sqrt
def sqrt(n)
raise
end
GC.stress = true
Prime.each(7*37){} rescue nil # <- Here we populate CC
class << Object.new; end
# These adjacent remove-then-alias maneuver
# frees a method entry, then immediately
# reuses it for another.
remove_method :sqrt
alias sqrt org_sqrt
end
Prime.each(7*37).to_a # <- SEGV
```
|
|
|
|
Currently, there is not a way to create a sized enumerator in C
with a different set of arguments than provided by Ruby, and
correctly handle keyword arguments. This function allows that.
The need for this is fairly uncommon, but it occurs at least in
Enumerator.produce, which takes arugments from Ruby but calls
rb_enumeratorize_with_size with a different set of arguments.
Notes:
Merged: https://github.com/ruby/ruby/pull/2509
|
|
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw,
and rb_yield_splat_kw. This functions are necessary to easily
handle cases where rb_funcall_passing_block, rb_funcallv_public,
and rb_yield_splat are currently used and a keyword argument
separation warning is raised.
Notes:
Merged: https://github.com/ruby/ruby/pull/2507
|
|
Now that we have eliminated most destructive operations over the
rb_method_entry_t / rb_callable_method_entry_t, let's make them
mostly immutabe and mark them const.
One exception is rb_export_method(), which destructively modifies
visibilities of method entries. I have left that operation as is
because I suspect that destructiveness is the nature of that
function.
Notes:
Merged: https://github.com/ruby/ruby/pull/2486
|
|
https://github.com/ruby/stringio/commit/f0e5027279
|
|
https://github.com/ruby/stringio/commit/5892663e32
|
|
https://github.com/ruby/stringio/commit/a37ab7c419
|
|
https://github.com/ruby/stringio/commit/e8065153b8
|
|
https://github.com/ruby/stringio/commit/4dfd997e0a
|
|
https://github.com/ruby/zlib/commit/00ead8cb2c
|
|
https://github.com/ruby/zlib/commit/8f43b264cd
|
|
This fixes instance_exec and similar methods. It also fixes
Enumerator::Yielder#yield, rb_yield_block, and a couple of cases
with Proc#{<<,>>}.
This support requires the addition of rb_yield_values_kw, similar to
rb_yield_values2, for passing the keyword flag.
Unlike earlier attempts at this, this does not modify the rb_block_call_func
type or add a separate function type. The functions of type
rb_block_call_func are called by Ruby with a separate VM frame, and we can
get the keyword flag information from the VM frame flags, so it doesn't need
to be passed as a function argument.
These changes require the following VM functions accept a keyword flag:
* vm_yield_with_cref
* vm_yield
* vm_yield_with_block
Notes:
Merged: https://github.com/ruby/ruby/pull/2493
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/2453
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/2484
|
|
OpenSSL::SSL::SSLSocket#sys{read,write}_nonblock
It's unlikely anyone would actually hit these. The methods are
private, you only hit this code path if calling these methods
before performing the SSL connection, and there is already a
verbose warning issued.
Notes:
Merged: https://github.com/ruby/ruby/pull/2484
|
|
https://github.com/ruby/io-console/commit/3d69c577a4
|
|
https://github.com/ruby/io-console/commit/77ed8d5a06
|
|
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.
This makes the following changes to : handling.
* Treats as **kw, prompting keyword argument separation warnings
if called with a positional hash.
* Do not look for an option hash if empty keywords are provided.
For backwards compatibility, treat an empty keyword splat as a empty
mandatory positional hash argument, but emit a a warning, as this
behavior will be removed in Ruby 3. The argument number check
needs to be moved lower so it can correctly handle an empty
positional argument being added.
* If the last argument is nil and it is necessary to treat it as an option
hash in order to make sure all arguments are processed, continue to
treat the last argument as the option hash. Emit a warning in this case,
as this behavior will be removed in Ruby 3.
* If splitting the keyword hash into two hashes, issue a warning, as we
will not be splitting hashes in Ruby 3.
* If the keyword argument is required to fill a mandatory positional
argument, continue to do so, but emit a warning as this behavior will
be going away in Ruby 3.
* If keyword arguments are provided and the last argument is not a hash,
that indicates something wrong. This can happen if a cfunc is calling
rb_scan_args multiple times, and providing arguments that were not
passed to it from Ruby. Callers need to switch to the new
rb_scan_args_kw function, which allows passing of whether keywords
were provided.
This commit fixes all warnings caused by the changes above.
It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used. If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.
In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby. The last argument may or may not be a hash,
so we can't set keyword argument mode. However, if it is a
hash, we don't want to warn when treating it as keywords.
In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args. Also, make
sure not to pass nil in place of an option hash.
Work around Kernel#warn warnings due to problems in the Rubygems
override of the method. There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.
Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
Notes:
Merged-By: jeremyevans <code@jeremyevans.net>
|