Граф коммитов

1514 Коммитов

Автор SHA1 Сообщение Дата
eileencodes b91b3bc771 Add a cache for class variables
Redo of 34a2acdac788602c14bf05fb616215187badd504 and
931138b00696419945dc03e10f033b1f53cd50f3 which were reverted.

GitHub PR #4340.

This change implements a cache for class variables. Previously there was
no cache for cvars. Cvar access is slow due to needing to travel all the
way up th ancestor tree before returning the cvar value. The deeper the
ancestor tree the slower cvar access will be.

The benefits of the cache are more visible with a higher number of
included modules due to the way Ruby looks up class variables. The
benchmark here includes 26 modules and shows with the cache, this branch
is 6.5x faster when accessing class variables.

```
compare-ruby: ruby 3.1.0dev (2021-03-15T06:22:34Z master 9e5105c) [x86_64-darwin19]
built-ruby: ruby 3.1.0dev (2021-03-15T12:12:44Z add-cache-for-clas.. c6be009) [x86_64-darwin19]

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|vm_cvar  |      5.681M|   36.980M|
|         |           -|     6.51x|
```

Benchmark.ips calling `ActiveRecord::Base.logger` from within a Rails
application. ActiveRecord::Base.logger has 71 ancestors. The more
ancestors a tree has, the more clear the speed increase. IE if Base had
only one ancestor we'd see no improvement. This benchmark is run on a
vanilla Rails application.

Benchmark code:

```ruby
require "benchmark/ips"
require_relative "config/environment"

Benchmark.ips do |x|
  x.report "logger" do
    ActiveRecord::Base.logger
  end
end
```

Ruby 3.0 master / Rails 6.1:

```
Warming up --------------------------------------
              logger   155.251k i/100ms
Calculating -------------------------------------
```

Ruby 3.0 with cvar cache /  Rails 6.1:

```
Warming up --------------------------------------
              logger     1.546M i/100ms
Calculating -------------------------------------
              logger     14.857M (± 4.8%) i/s -     74.198M in   5.006202s
```

Lastly we ran a benchmark to demonstate the difference between master
and our cache when the number of modules increases. This benchmark
measures 1 ancestor, 30 ancestors, and 100 ancestors.

Ruby 3.0 master:

```
Warming up --------------------------------------
            1 module     1.231M i/100ms
          30 modules   432.020k i/100ms
         100 modules   145.399k i/100ms
Calculating -------------------------------------
            1 module     12.210M (± 2.1%) i/s -     61.553M in   5.043400s
          30 modules      4.354M (± 2.7%) i/s -     22.033M in   5.063839s
         100 modules      1.434M (± 2.9%) i/s -      7.270M in   5.072531s

Comparison:
            1 module: 12209958.3 i/s
          30 modules:  4354217.8 i/s - 2.80x  (± 0.00) slower
         100 modules:  1434447.3 i/s - 8.51x  (± 0.00) slower
```

Ruby 3.0 with cvar cache:

```
Warming up --------------------------------------
            1 module     1.641M i/100ms
          30 modules     1.655M i/100ms
         100 modules     1.620M i/100ms
Calculating -------------------------------------
            1 module     16.279M (± 3.8%) i/s -     82.038M in   5.046923s
          30 modules     15.891M (± 3.9%) i/s -     79.459M in   5.007958s
         100 modules     16.087M (± 3.6%) i/s -     81.005M in   5.041931s

Comparison:
            1 module: 16279458.0 i/s
         100 modules: 16087484.6 i/s - same-ish: difference falls within error
          30 modules: 15891406.2 i/s - same-ish: difference falls within error
```

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-06-18 10:02:44 -07:00
Nobuyoshi Nakada 43ed1e68a1
Make ext directory before extinit.c when out-of-place build 2021-06-16 00:08:28 +09:00
Takashi Kokubun d281fc525d
Add missing dependencies
https://github.com/ruby/ruby/runs/2791163586?check_suite_focus=true
2021-06-10 00:53:28 -07:00
Takashi Kokubun c5e8a49bde
Avoid enqueueing the same ISeq twice
by a race condition by multiple Ractors.

Atmically incrementing body->total_calls may have its own cost, so for
now we intentionally leave the unreliable total_calls. So we allow an
ISeq to be never pushed when you use multiple Ractors. However, if you
enqueue a single ccan node twice, get_from_list loops infinitely. Thus
this patch takes care of such a situation.
2021-06-10 00:32:24 -07:00
S.H 28b481938b
Implemented some NilClass method in Ruby code is faster [Feature #17054] (#3366) 2021-06-02 20:04:56 -07:00
Takashi Kokubun 1aac0e8819
Mark inlined ISeqs during MJIT compilation (#4539)
[Bug #17584]
2021-05-30 21:42:02 -07:00
卜部昌平 2bc293e899 cdhash_cmp: can take rational literals
Rational literals are those integers suffixed with `r`.  They tend to
be a part of more complex expressions like `123/456r`, but in theory
they can live alone.  When such "bare" rational literals are passed to
case-when branch, we have to take care of them.  Fixes [Bug #17854]
2021-05-12 10:30:46 +09:00
Aaron Patterson 07f055bb13
Revert "Filling cache values on cvar write"
This reverts commit 08de37f9fa.
This reverts commit e8ae922b62.
2021-05-11 13:31:00 -07:00
eileencodes e8ae922b62 Add a cache for class variables
This change implements a cache for class variables. Previously there was
no cache for cvars. Cvar access is slow due to needing to travel all the
way up th ancestor tree before returning the cvar value. The deeper the
ancestor tree the slower cvar access will be.

The benefits of the cache are more visible with a higher number of
included modules due to the way Ruby looks up class variables. The
benchmark here includes 26 modules and shows with the cache, this branch
is 6.5x faster when accessing class variables.

```
compare-ruby: ruby 3.1.0dev (2021-03-15T06:22:34Z master 9e5105ca45) [x86_64-darwin19]
built-ruby: ruby 3.1.0dev (2021-03-15T12:12:44Z add-cache-for-clas.. c6be0093ae) [x86_64-darwin19]

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|vm_cvar  |      5.681M|   36.980M|
|         |           -|     6.51x|
```

Benchmark.ips calling `ActiveRecord::Base.logger` from within a Rails
application. ActiveRecord::Base.logger has 71 ancestors. The more
ancestors a tree has, the more clear the speed increase. IE if Base had
only one ancestor we'd see no improvement. This benchmark is run on a
vanilla Rails application.

Benchmark code:

```ruby
require "benchmark/ips"
require_relative "config/environment"

Benchmark.ips do |x|
  x.report "logger" do
    ActiveRecord::Base.logger
  end
end
```

Ruby 3.0 master / Rails 6.1:

```
Warming up --------------------------------------
              logger   155.251k i/100ms
Calculating -------------------------------------
```

Ruby 3.0 with cvar cache /  Rails 6.1:

```
Warming up --------------------------------------
              logger     1.546M i/100ms
Calculating -------------------------------------
              logger     14.857M (± 4.8%) i/s -     74.198M in   5.006202s
```

Lastly we ran a benchmark to demonstate the difference between master
and our cache when the number of modules increases. This benchmark
measures 1 ancestor, 30 ancestors, and 100 ancestors.

Ruby 3.0 master:

```
Warming up --------------------------------------
            1 module     1.231M i/100ms
          30 modules   432.020k i/100ms
         100 modules   145.399k i/100ms
Calculating -------------------------------------
            1 module     12.210M (± 2.1%) i/s -     61.553M in   5.043400s
          30 modules      4.354M (± 2.7%) i/s -     22.033M in   5.063839s
         100 modules      1.434M (± 2.9%) i/s -      7.270M in   5.072531s

Comparison:
            1 module: 12209958.3 i/s
          30 modules:  4354217.8 i/s - 2.80x  (± 0.00) slower
         100 modules:  1434447.3 i/s - 8.51x  (± 0.00) slower
```

Ruby 3.0 with cvar cache:

```
Warming up --------------------------------------
            1 module     1.641M i/100ms
          30 modules     1.655M i/100ms
         100 modules     1.620M i/100ms
Calculating -------------------------------------
            1 module     16.279M (± 3.8%) i/s -     82.038M in   5.046923s
          30 modules     15.891M (± 3.9%) i/s -     79.459M in   5.007958s
         100 modules     16.087M (± 3.6%) i/s -     81.005M in   5.041931s

Comparison:
            1 module: 16279458.0 i/s
         100 modules: 16087484.6 i/s - same-ish: difference falls within error
          30 modules: 15891406.2 i/s - same-ish: difference falls within error
```

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-05-11 12:04:27 -07:00
Nobuyoshi Nakada 6943ffc3d5
Split revision.h rule
GNU-make specific rule is defined in defs/gmake.mk.
2021-04-18 13:47:43 +09:00
卜部昌平 6413dc27dc dependency updates 2021-04-13 14:30:21 +09:00
Nobuyoshi Nakada 12f7ba5ed4
Make String#crypt ractor-safe 2021-04-13 12:05:31 +09:00
Nobuyoshi Nakada 68a6f6c4ab
mac: ignore SDKROOT at installation 2021-04-10 11:57:45 +09:00
Nobuyoshi Nakada 041a4f9a5e
Stop downloading Unicode files twice
These files should have been downloaded in update-remote.
2021-03-26 00:38:35 +09:00
Kazuhiro NISHIYAMA f45bed0a6e
Use XRUBY to expand path instead of platform dependent 2021-03-25 18:06:06 +09:00
Nobuyoshi Nakada e7dc6f2a3c
Generate encoding header before enc.mk
As some encodings need the corresponding header.
2021-03-25 17:10:53 +09:00
Nobuyoshi Nakada cda60ee6d5
Keep unicode_normalize/tables.rb as-is
Define no dependency unless ALWAYS_UPDATE_UNICODE is set to yes,
so that `make prog` works in a just-checkedout working directory.
2021-03-25 15:45:20 +09:00
Kazuhiro NISHIYAMA 12812c2bdf
Fix test-bundler-parallel errors when out-of-place build 2021-03-25 14:59:15 +09:00
Nobuyoshi Nakada b1149bf305
Make the commit of updated bundled_gems file 2021-02-16 19:54:16 +09:00
Nobuyoshi Nakada 4f47d655e3 Added Thread::Backtrace.limit [Feature #17479] 2021-02-15 18:29:35 +09:00
Takashi Kokubun 27382eb9fc
Add a benchmark-driver runner for Ractor (#4172)
* Add a benchmark-driver runner for Ractor

* Process.clock_gettime(Process:CLOCK_MONOTONIC) could be slow

in Ruby 3.0 Ractor

* Fetching Time could also be slow

* Fix a comment

* Assert overriding a private method
2021-02-10 21:24:25 -08:00
Samuel Williams 5f69a7f604
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`.

* Use public interface if available.

* Use `rb_check_funcall` where possible.

* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00
Nobuyoshi Nakada 0dd38902b9
Ignore warnings when transforming preprocessed header
For already preprocessed header, -Werror=misleading-indentation
doesn't make sense.
2021-02-01 18:16:39 +09:00
Nobuyoshi Nakada ed6dc066b6
CFLAGS includes ARCH_FLAG 2021-01-26 22:19:00 +09:00
Nobuyoshi Nakada 4de228b6bc
Sort autogenerated dependencies [ci skip] 2021-01-23 20:56:15 +09:00
Nobuyoshi Nakada 899b950647
Remove common output directory 2021-01-22 18:37:31 +09:00
Takashi Kokubun 5cf6229ee9
Skip updating exts in also test-spec to reduce the turnaround time (#4089)
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

Partially reversing a4f3e1762a like 21df4dce53.
We usually run them through make check which has the dependency, and test-all and test-spec without the dependency are useful for running only individual tests.
2021-01-18 07:14:02 -08:00
Nobuyoshi Nakada 2adbf01ae1
dtoa.c: make thread-safe by using atomic CAS 2021-01-10 18:19:53 +09:00
Koichi Sasada e91160f757 set RUBY_ON_BUG on runruby rule.
set RUBY_ON_BUG='gdb -x $(srcdir)/.gdbinit -p' to catch SEGV
on `make runruby` rule.
2021-01-05 16:50:00 +09:00
Nobuyoshi Nakada 3adf84a079
Commented out the sh-specific code, in cmd.exe 2021-01-05 11:53:41 +09:00
Takashi Kokubun cf4a6b5e7b
Add a missing dependency 2021-01-03 22:48:13 -08:00
Takashi Kokubun 4182035e27
Add -v to make benchmark
I simply can't tell which of compare-ruby and built-ruby is what.
2021-01-01 18:41:22 -08:00
S.H daec5f9edc
Improve performance some Float methods [Feature #17498] (#4018) 2021-01-01 18:39:07 -08:00
Nobuyoshi Nakada 93735f8fc0
Moved time.rb to timev.rb 2020-12-31 17:23:37 +09:00
Nobuyoshi Nakada d5fb51d2d3
Add time.rb as builtin 2020-12-31 15:19:06 +09:00
Nobuyoshi Nakada 2f42243bce Make more silent when -s on GNU make 2020-12-29 17:45:19 +09:00
Nobuyoshi Nakada d57c5a7b61 transcode-tblgen.rb: make silent a little when just -v 2020-12-29 17:45:19 +09:00
Takashi Kokubun c0a2d322c6
Update help of sync-default-gems 2020-12-28 23:03:04 -08:00
Nobuyoshi Nakada 2556cd3f51 Bypass check for warning_category on internal calls 2020-12-28 12:44:03 +09:00
Nobuyoshi Nakada a042043487
Do not include external library sources into packages 2020-12-27 23:33:56 +09:00
Nobuyoshi Nakada 6ed6b85ece Expose atomic operation macros with RUBY prefix
Now we need atomic operations, which are lighter than mutex, more
widely for extension libraries because of Ractor.
2020-12-24 11:43:21 +09:00
Koichi Sasada a2950369bd TracePoint.new(&block) should be ractor-local
TracePoint should be ractor-local because the Proc can violate the
Ractor-safe.
2020-12-22 00:03:00 +09:00
Koichi Sasada 6be61ab264 should use owned_p instead of locked_p
It should raise an error if the same thread tris to call
receive/receive_if.
2020-12-21 02:39:34 +09:00
Koichi Sasada c58142134c make RB_DEBUG_COUNTER_INC()_thread-safe 2020-12-17 03:43:59 +09:00
Kenta Murata 1bafb3cb47
[memory_view] Make MemoryView API Ractor-safe (#3911)
* memory_view.c: make Ractor-safe

* test/ruby/test_memory_view.rb: Add test_ractor

* memory_view: fix typo

* memory_view.c: Use st_update in unregster_exported_object

* memory_view: update dependency
2020-12-16 13:43:56 +09:00
Koichi Sasada 0b678cc9e5 add vm_sync debug counters
* vm_sync_lock
* vm_sync_lock_enter
* vm_sync_lock_enter_nb
* vm_sync_lock_enter_cr
* vm_sync_barrier
2020-12-16 10:38:12 +09:00
Alan Wu 25a48b703e Update dependencies 2020-12-14 17:56:42 -05:00
Koichi Sasada 70a311fdeb trap on non-main ractor
trap can accept blopck/Proc and it can violate Rator isolation,
so the Proc should be isolatable when trap is used on non-main ractor.
2020-12-12 08:36:52 +09:00
Koichi Sasada ad6573163f add RUNOPT and RUNOPT0 for dev rules.
run, runruby, ... accept RUNOPT and RUNOPT0 configuration to pass
some commandline argument like that:

  $(BTESTRUBY) $(RUNOPT0) $(TESTRUN_SCRIPT) $(RUNOPT)

RUNOPT0 is options for ruby interpreter (-w, -v, ...)
RUNOPT is options for the script (ARGV/ARGF)
2020-12-11 11:57:25 +09:00
Hiroshi SHIBATA 087ac34fb2 Added tool/lib into test-spec loadpath 2020-12-10 18:06:25 +09:00