Commit graph

63490 commits

Author SHA1 Message Date
Koichi Sasada
ea78960ee5 sync callable_method_entry()
callable_method_entry() read/write method table structures so that
this function should be synchronized between Ractors.
2020-09-10 18:44:02 +09:00
Aaron Patterson
475c8701d7 Make SecureRandom support Ractor
SecureRandom lazily defines `get_random`.  Accessing the mutex to define
the `get_random` method is not supported inside a Ractor.  This commit
defines `gen_random` when `securerandom` is required and makes it
suppore Ractor (as well as thread safe).

Here is a test program:

```ruby
require "securerandom"

r = Ractor.new do
  loop do
    Ractor.yield SecureRandom.hex
  end
end

p r.take
```

Before this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
<internal:ractor>:124:in `take': thrown by remote Ractor. (Ractor::RemoteError)
	from ./test.rb:9:in `<main>'
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
	from /Users/aaron/git/ruby/lib/securerandom.rb:155:in `random_bytes'
	from /Users/aaron/git/ruby/lib/securerandom.rb:176:in `hex'
	from ./test.rb:5:in `block (2 levels) in <main>'
	from ./test.rb:4:in `loop'
	from ./test.rb:4:in `block in <main>'
make: *** [runruby] Error
```

After this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
<internal:ractor>:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
"3fc8885157e3911bab4b5d7619bb0308"
```
2020-09-09 12:45:43 -07:00
Jean Boussier
5001cc4716 Optimize ObjectSpace.dump_all
The two main optimization are:
  - buffer writes for improved performance
  - avoid formatting functions when possible

```

|                   |compare-ruby|built-ruby|
|:------------------|-----------:|---------:|
|dump_all_string    |       1.038|   195.925|
|                   |           -|   188.77x|
|dump_all_file      |      33.453|   139.645|
|                   |           -|     4.17x|
|dump_all_dev_null  |      44.030|   278.552|
|                   |           -|     6.33x|
```
2020-09-09 11:11:36 -07:00
git
76c7146ab4 * 2020-09-10 [ci skip] 2020-09-10 00:05:36 +09:00
Jean Boussier
b49a870414 Add a :since option to dump_all
This is useful to see what a block of code allocated, e.g.

```
GC.start
GC.disable
ObjectSpace.trace_object_allocations do
  # run some code
end
gc_gen = GC.count
allocations = ObjectSpace.dump_all(output: :file, since: gc_gen)
GC.enable
GC.start
retentions = ObjectSpace.dump_all(output: :file, since: gc_gen)
```
2020-09-09 08:05:14 -07:00
Hiroshi SHIBATA
01828a955a
Promote tsort to default gems 2020-09-09 21:53:09 +09:00
Hiroshi SHIBATA
b194973dcd
Revert the related commits about Tempfile.open change.
Start with fa21985a7a
  to d7492a0be8
2020-09-09 21:10:48 +09:00
Jeremy Evans
6997109fca [ruby/tempfile] Revert Tempfile.open unlinking the file
Document difference in behavior between Tempfile.open and
Tempfile.create.

426d6f887f
2020-09-09 20:15:41 +09:00
git
96f2b2e086 * 2020-09-09 [ci skip] 2020-09-09 01:23:52 +09:00
Takashi Kokubun
65ab2385e3
Use size_t for MJIT's max_ivar_index
iseq_inline_iv_cache_entry's index is also size_t.
%"PRIuSIZE" seems to print warnings against st_index_t in some environments.
2020-09-08 09:22:34 -07:00
Hiroshi SHIBATA
b7d86e330c
Workaroud for macOS Big Sur(11.0) 2020-09-08 20:39:23 +09:00
Hiroshi SHIBATA
cdef17096c
libSystem.dylib is also symlink. Use libSystem.B.dylib 2020-09-08 20:38:01 +09:00
Hiroshi SHIBATA
0168094da2
Use libSystem.dylib instead of libm.dylib and libc.dylib
Because macOS 11.0(Big Sur) was removed libc and libm from `/usr/lib`.
2020-09-08 19:35:15 +09:00
git
4530bea88c * 2020-09-08 [ci skip] 2020-09-08 10:31:51 +09:00
Kazuhiro NISHIYAMA
5be75aad37
Add FALLTHROUGH
Pointed out by Coverity Scan

```
** CID 1466646: Control flow issues (MISSING_BREAK)
/ext/-test-/random/loop.c: 63 in loop_get_bytes()
```
2020-09-08 10:30:07 +09:00
Nobuyoshi Nakada
2b07b24bdf Added rb_random_base_init
To enclose the initialization of Random::Base part.
2020-09-07 20:08:01 +09:00
Nobuyoshi Nakada
4924011262 Added WITH_REAL macros
Added `WITH_REAL` versions to `RB_RANDOM_INTERFACE` macros.  Also
these macros including "without real" versions no longer contain
the terminator (semicolon and comma).
2020-09-07 20:08:01 +09:00
Nobuyoshi Nakada
d6ec0ef59b Added get_real interface 2020-09-07 20:08:01 +09:00
Nobuyoshi Nakada
c449b9b02f Added rb_int_pair_to_real 2020-09-07 20:08:01 +09:00
Nobuyoshi Nakada
af5e87ab21 separate rb_random_t
* random.c: separate abstract rb_random_t and rb_random_mt_t for
  Mersenne Twister implementation.

* include/ruby/random.h: the interface for extensions of Random
  class.

* DLL imported symbol reference is not constant on Windows.

* check if properly initialized.
2020-09-07 20:08:01 +09:00
Nobuyoshi Nakada
f4d5273989 Random::Base
* random.c (InitVM_Random): introduce abstract super class
  Random::Base.
2020-09-07 20:08:01 +09:00
卜部昌平
19917d45a3 .github: try GitHub Container Registry
It is natural for a CI running on GitHub to use GitHub's facility.

See also https://github.blog/2020-09-01-introducing-github-container-registry/
2020-09-07 19:02:45 +09:00
git
17a27060a7 * 2020-09-07 [ci skip] 2020-09-07 13:29:42 +09:00
Nobuyoshi Nakada
0dbf6e46fb
[Feature #17157] removed -T command line option 2020-09-07 00:59:53 +09:00
Samuel Williams
b22b3f03f4 Increase timeout for GitHub Actions. 2020-09-06 22:11:49 +12:00
Kazuhiro NISHIYAMA
c19f8f6263
Add *.md to doc/.document [ci skip] 2020-09-06 19:05:30 +09:00
Yusuke Endoh
369cfabd59 Make it possible to dump and load an exception object
A backtrace object in an exception had never supported marshalling
correctly: `Marshal.load(Marshal.dump(exc)).backtrace_locations` dumped
core.

An Exception object has two hidden instance varibles for backtrace data:
one is "bt", which has an Array of Strings, and the other is
"bt_locations", which has an Array of Thread::Backtrace::Locations.
However, Exception's dump outputs data so that the two variables are the
same Array of Strings. Thus, "bt_locations" had a wrong-type object.

For the compatibility, it is difficult to change the dump format.  This
changeset fixes the issue by ignoring data for "bt_locations" at the
loading phase if "bt_locations" refers to the same object as "bt".

Future work: Exception's dump should output "bt_locations"
appropriately.

https://bugs.ruby-lang.org/issues/17150
2020-09-06 13:57:41 +09:00
Samuel Williams
c12b2703bc Add RB_ prefix for size_t to number conversion. 2020-09-06 15:37:54 +12:00
Ashwin Elangovan
40c06e6fe1
Fixed some typos in ractor.md (#3522) 2020-09-05 15:58:31 -04:00
git
dfefe0e0d0 * 2020-09-06 [ci skip] 2020-09-06 01:59:20 +09:00
Kazuhiro NISHIYAMA
776b3df490
Fix typos [ci skip] 2020-09-06 01:58:44 +09:00
Nobuyoshi Nakada
170c7528e6
common.mk: UNALIGNED_MEMBER_ACCESS needs internal/warnings.h on some platforms 2020-09-05 23:16:26 +09:00
Nobuyoshi Nakada
dd83d0c599
update-deps: ruby-runner is not a target 2020-09-05 23:16:23 +09:00
Nobuyoshi Nakada
5c49bb5486
Removed useless casts 2020-09-05 17:34:12 +09:00
andrewmelis
72757fb596 Fix typo in ractor.md 2020-09-05 17:21:43 +09:00
Tom Schady
de30450d91 Fix typos in Ractor README. 2020-09-04 12:41:35 -04:00
git
1c8fe90760 * 2020-09-05 [ci skip] 2020-09-05 00:42:35 +09:00
Nobuyoshi Nakada
f943566d1c
break around function definition [ci skip] 2020-09-05 00:34:58 +09:00
Nobuyoshi Nakada
1c78f5d5b8
Sort links in NEWS.md by URI [ci skip] 2020-09-04 22:20:46 +09:00
Nobuyoshi Nakada
eb67c603ca
Added Symbol#name
https://bugs.ruby-lang.org/issues/16150#change-87446
2020-09-04 22:18:59 +09:00
Nobuyoshi Nakada
d7406ccc2c
Updated dependency 2020-09-04 16:28:40 +09:00
Nobuyoshi Nakada
d164eef957
Fixed heap-use-after-free on racter 2020-09-04 15:17:42 +09:00
Marc-Andre Lafortune
fbaab562d9 lib/ostruct.rb: Revert "To use RuntimeError instead of FrozenError for old ruby versions."
This reverts commit 4cd1fc8b3559353069860eee90b1b5bade013917.
2020-09-04 01:23:14 -04:00
Koichi Sasada
3b0bcaf287 check multi_ractor mode at main_p
rb_ractor_main_p() need to access to the ractor pointer in TLS.
However it is slow operation so that we need to skip this check
if it is not multi-ractor mode (!ruby_multi_ractor).

This performance regression is pointed at
https://bugs.ruby-lang.org/issues/17100#note-27
2020-09-04 14:18:48 +09:00
Nobuyoshi Nakada
169b1d1aca
Initialize loop variables of list_for_each for MS VC 2020-09-04 11:46:50 +09:00
Alan Wu
d4585e7470 Avoid potential for rb_raise() while crashing
rb_obj_raw_info is called while printing out crash messages and
sometimes called during garbage collection. Calling rb_raise() in these
situations is undesirable because it can start executing ensure blocks.
2020-09-03 17:41:58 -04:00
git
e0a749c045 * 2020-09-04 [ci skip] 2020-09-04 04:09:05 +09:00
Koichi Sasada
3f922f3b77 don't use toplevel return
Toplevel return is supported after Ruby 2.4, so don't use it
for older BASERUBY.
2020-09-04 04:07:34 +09:00
Koichi Sasada
b52513e2a1 skip Ractor tests on Compiler tests
This implementation has memory corruption errors so and
it causes BUG on rare occasions. This commit skips
suspect tests on Github actions Compiler tests.
2020-09-03 21:11:06 +09:00
Koichi Sasada
79df14c04b Introduce Ractor mechanism for parallel execution
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.

[Feature #17100]

This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.

I hope this feature can help programmers from thread-safety issues.
2020-09-03 21:11:06 +09:00