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

1990 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 0bff07644b
Make YJIT a GC root rather than an object (#11343)
YJIT currently uses the YJIT root object to mark objects during GC and
update references during compaction. This object otherwise serves no
purpose.

This commit changes it YJIT to be step when marking the GC root. This
saves some memory from being allocated from the system and the GC.
2024-08-08 12:19:35 -04:00
Jun Aruga aed468ae0b CI: Run annocheck for libruby.so
When building with the `--shared` option, most functionality is kept in
`libruby.so`. Therefore also run annocheck for `libruby.so`.

Use `ARG IN_DIR` to propagate multiple files into the container instead of
`ARG FILES` in the `Dockerfile-copy`. Because the `COPY` syntax in Dockerfile
doesn't support copying the multiple files.
https://stackoverflow.com/questions/61599384/specify-multiple-files-in-arg-to-copy-in-dockerfile

Co-authored-by: Vít Ondruch <vondruch@redhat.com>
2024-08-07 18:51:20 +02:00
Alan Wu 0ada02abe2 Put the default GC implementation back into gc.o
We discovered that having gc.o and gc_impl.o in separate translation
units diminishes codegen quality with GCC 11 on x86-64. This commit
solves that problem by including default/gc.c into gc.c, letting the
optimizer have visibility into the body of functions again in builds
not using link-time optimization, which are common.

This effectively restores things to the way they were before
[Feature #20470] from the optimizer's perspective while maintaining the
ability to build gc/default.c as a DSO.

There were a few functions duplicated across gc.c and gc/default.c.
Extract them and put them into gc/gc.h.
2024-07-26 11:44:34 -04:00
Peter Zhu db3472d84c Set `BUILDING_SHARED_GC` when building shared GC 2024-07-16 09:09:41 -04:00
Peter Zhu 461a7b8316 Add gc/gc.h for functions in gc.c and used by GC implementations 2024-07-15 08:57:14 -04:00
Matt Valentine-House f543c68e1c Provide GC.config to disable major GC collections
This feature provides a new method `GC.config` that configures internal
GC configuration variables provided by an individual GC implementation.

Implemented in this PR is the option `full_mark`: a boolean value that
will determine whether the Ruby GC is allowed to run a major collection
while the process is running.

It has the following semantics

This feature configures Ruby's GC to only run minor GC's. It's designed
to give users relying on Out of Band GC complete control over when a
major GC is run. Configuring `full_mark: false` does two main things:

* Never runs a Major GC. When the heap runs out of space during a minor
  and when a major would traditionally be run, instead we allocate more
  heap pages, and mark objspace as needing a major GC.
* Don't increment object ages. We don't promote objects during GC, this
  will cause every object to be scanned on every minor. This is an
  intentional trade-off between minor GC's doing more work every time,
  and potentially promoting objects that will then never be GC'd.

The intention behind not aging objects is that users of this feature
should use a preforking web server, or some other method of pre-warming
the oldgen (like Nakayoshi fork)before disabling Majors. That way most
objects that are going to be old will have already been promoted.

This will interleave major and minor GC collections in exactly the same
what that the Ruby GC runs in versions previously to this. This is the
default behaviour.

* This new method has the following extra semantics:
  - `GC.config` with no arguments returns a hash of the keys of the
    currently configured GC
  - `GC.config` with a key pair (eg. `GC.config(full_mark: true)` sets
    the matching config key to the corresponding value and returns the
    entire known config hash, including the new values. If the key does
    not exist, `nil` is returned

* When a minor GC is run, Ruby sets an internal status flag to determine
  whether the next GC will be a major or a minor. When `full_mark:
  false` this flag is ignored and every GC will be a minor.

  This status flag can be accessed at
  `GC.latest_gc_info(:needs_major_by)`. Any value other than `nil` means
  that the next collection would have been a major.

  Thus it's possible to use this feature to check at a predetermined
  time, whether a major GC is necessary and run one if it is. eg. After
  a request has finished processing.

  ```ruby
  if GC.latest_gc_info(:needs_major_by)
    GC.start(full_mark: true)
  end
  ```

[Feature #20443]
2024-07-12 14:43:33 +01:00
Peter Zhu 00d0ddd48a Add gc/gc_impl.h for GC implementation headers 2024-07-12 08:41:33 -04:00
Peter Zhu a0469a4788 Rename gc/gc_impl.c to gc/default.c
Changing the name makes it clear that this is the default GC in Ruby.
2024-07-11 09:09:47 -04:00
Peter Zhu e5d12f9cce Move gc_impl.c to gc/gc_impl.c
This commit creates a new directory `gc` to put different GC
implementations and moves the default GC from gc_impl.c to gc/gc_impl.c.
The default GC can be easily switched using the `BUILTIN_GC` variable
in Makefile.in.
2024-07-11 09:09:47 -04:00
Peter Zhu a9f6bd028a Add make target shared-gc
Allows building shared GC using `make shared-gc SHARED_GC=gc_impl`
2024-07-08 16:47:25 -04:00
Jean Boussier 9594db0cf2 Implement Hash.new(capacity:)
[Feature #19236]

When building a large hash, pre-allocating it with enough
capacity can save many re-hashes and significantly improve
performance.

```
/opt/rubies/3.3.0/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::../miniruby-master -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby --disable-gem" \
	            --output=markdown --output-compare -v $(find ./benchmark -maxdepth 1 -name 'hash_new' -o -name '*hash_new*.yml' -o -name '*hash_new*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-03-25T11:48:11Z master f53209f023) +YJIT dev [arm64-darwin23]
last_commit=[ruby/irb] Cache RDoc::RI::Driver.new (https://github.com/ruby/irb/pull/911)
built-ruby: ruby 3.4.0dev (2024-03-25T15:29:40Z hash-new-rb 77652b08a2) +YJIT dev [arm64-darwin23]
warming up...

|                    |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|new                 |      7.614M|    5.976M|
|                    |       1.27x|         -|
|new_with_capa_1k    |     13.931k|   15.698k|
|                    |           -|     1.13x|
|new_with_capa_100k  |     124.746|   148.283|
|                    |           -|     1.19x|
```
2024-07-08 12:24:33 +02:00
Peter Zhu 9d3a58f364 [Feature #20470] Update dependencies 2024-07-03 09:03:40 -04:00
Peter Zhu 51bd816517 [Feature #20470] Split GC into gc_impl.c
This commit splits gc.c into two files:

- gc.c now only contains code not specific to Ruby GC. This includes
  code to mark objects (which the GC implementation may choose not to
  use) and wrappers for internal APIs that the implementation may need
  to use (e.g. locking the VM).

- gc_impl.c now contains the implementation of Ruby's GC. This includes
  marking, sweeping, compaction, and statistics. Most importantly,
  gc_impl.c only uses public APIs in Ruby and a limited set of functions
  exposed in gc.c. This allows us to build gc_impl.c independently of
  Ruby and plug Ruby's GC into itself.
2024-07-03 09:03:40 -04:00
Kevin Newton fa038f838f [PRISM] Strip out common.mk for pm_string_list 2024-06-05 14:40:03 -04:00
Jean Boussier 7c12169230 Eliminate internal uses of `Data_Wrap_Struct`
Ref: https://github.com/ruby/ruby/pull/10872

These should be the last internal uses of the old `Data` API
inside Ruby itself. Some use remain in a couple default gems.
2024-06-02 13:59:11 +02:00
Nobuyoshi Nakada 26bd4144f7
Add `nightly` recipe
Installs the last revision in the previous `RUBY_RELEASE_DATE`.
2024-06-02 18:36:09 +09:00
Nobuyoshi Nakada 0d44e23831
Prevent test-bundled-gems outputs from mixing
Run test-bundled-gems-run and test-bundled-gems-spec sequentially.
2024-05-26 22:17:57 +09:00
Kevin Newton 6c07aa364d [PRISM] Remove old prism spec workflow, just use default.mspec now 2024-05-20 12:28:47 -04:00
Hiroshi SHIBATA 9df3f205b1 test-syntax-suggest is not working with mswin environment 2024-05-09 15:22:53 +09:00
卜部昌平 c844968b72 ruby tool/update-deps --fix 2024-04-27 21:55:28 +09:00
Kevin Newton d3a7e55542
Update common.mk dependencies 2024-04-24 15:45:23 -04:00
Kevin Newton 58847b7df8 [PRISM] Generate inspect_visitor in common.mk 2024-04-24 14:16:42 -04:00
Nobuyoshi Nakada 66edc33f4e
[DOC] Wait for `docs` to complete before installing all
The document directories may be incomplete or empty before `docs` is
completed.
2024-04-24 12:06:20 +09:00
yui-knk 2992e1074a Refactor parser compile functions
Refactor parser compile functions to reduce the dependence
on ruby functions.
This commit includes these changes

1. Refactor `gets`, `input` and `gets_` of `parser_params`

Parser needs two different data structure to get next line, function (`gets`) and input data (`input`).
However `gets_` is used for both function (`call`) and input data (`ptr`).
`call` is used for managing general callback function when `rb_ruby_parser_compile_generic` is used.
`ptr` is used for managing the current pointer on String when `parser_compile_string` is used.
This commit changes parser to used only `gets` and `input` then removes `gets_`.

2. Move parser_compile functions and `gets` functions from parse.y to ruby_parser.c

This change reduces the dependence on ruby functions from parser.

3. Change ruby_parser and ripper to take care of `VALUE input` GC mark

Move the responsibility of calling `rb_gc_mark` for `VALUE input` from parser to ruby_parser and ripper.
`input` is arbitrary data pointer from the viewpoint of parser.

4. Introduce rb_parser_compile_array function

Caller of `rb_parser_compile_generic` needs to take care about GC because ruby_parser doesn’t know
about the detail of `lex_gets` and `input`.
Introduce `rb_parser_compile_array` to reduce the complexity of ast.c.
2024-04-23 07:20:22 +09:00
yui-knk d07df8567e Parser and universal parser share wrapper functions 2024-04-20 18:08:33 +09:00
Nobuyoshi Nakada c789e4c493
Use isolated temporary directory in test-all too for RubyGems tests 2024-04-19 23:06:46 +09:00
Nobuyoshi Nakada 801e4a4feb
Remove UPDATE_LIBRARIES
It has not been used since e48375c112.
2024-04-19 14:12:42 +09:00
Kevin Newton 51485e63fc [PRISM] Generate the reflection file 2024-04-17 13:54:29 -04:00
Kevin Newton 8c8068c06f [PRISM] Remove old make targets for state stack 2024-04-17 10:36:52 -04:00
Hiroshi SHIBATA cc37c89c2f Separate docs task from main to install-*
[Feature #20347]
2024-04-17 19:56:20 +09:00
yui-knk 6056773105 Move shareable_constant_value logic from parse.y to compile.c 2024-04-04 08:44:10 +09:00
Nobuyoshi Nakada 03ab4a56d2
Clean symlinks to be runnable [ci skip] 2024-03-28 23:58:07 +09:00
Takashi Kokubun 46bf6ae886
YJIT: Propagate Array, Hash, and String classes (#10323) 2024-03-25 12:06:47 -04:00
Nobuyoshi Nakada 7c015c3b30
Remove never used macros related to RJIT [ci skip]
These macros have not been used since the commit "Stop exporting
symbols for MJIT" 233ddfac54, and
renamed as RJIT.
2024-03-24 22:37:20 +09:00
Kevin Newton 0e8b6c62a4 [PRISM] Enable specs in CI 2024-03-20 14:28:13 -04:00
Kevin Newton 0b34b75ba1
[PRISM] Remove unnecessary dependencies in common.mk 2024-03-18 14:18:53 -04:00
Nobuyoshi Nakada 0fb39ab1b9
Clean intermediate files and debug info for each target
By replacing `ALLOBJS` suffix with intermediate file suffixes instead
of roughly removing by wildcards.  Made `cleanlibs` append `.dSYM`
suffix for each word in `TARGET_SO`, not the end of the entire list.
2024-03-10 22:12:00 +09:00
Nobuyoshi Nakada 1c083c4db0
Clean up files made by runnable in clean-runnable [ci skip] 2024-03-07 16:40:27 +09:00
Nobuyoshi Nakada 810779fab9
Clean up dump file generated by `--yjit-exit-locations` [ci skip] 2024-03-07 14:33:40 +09:00
Kevin Newton e13fd48f55 [PRISM] Update dependencies for prism diagnostics 2024-03-06 21:42:54 -05:00
Jean Boussier b4a69351ec Move FL_SINGLETON to FL_USER1
This frees FL_USER0 on both T_MODULE and T_CLASS.

Note: prior to this, FL_SINGLETON was never set on T_MODULE,
so checking for `FL_SINGLETON` without first checking that
`FL_TYPE` was `T_CLASS` was valid. That's no longer the case.
2024-03-06 13:11:41 -05:00
Peter Zhu a255b43ff1 Update common.mk 2024-02-23 17:17:12 -05:00
Takashi Kokubun 8a6740c70e
YJIT: Lazily push a frame for specialized C funcs (#10080)
* YJIT: Lazily push a frame for specialized C funcs

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>

* Fix a comment on pc_to_cfunc

* Rename rb_yjit_check_pc to rb_yjit_lazy_push_frame

* Rename it to jit_prepare_lazy_frame_call

* Fix a typo

* Optimize String#getbyte as well

* Optimize String#byteslice as well

---------

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2024-02-23 19:08:09 +00:00
Kevin Newton 9a09e27a73 [PRISM] Use new static literal comparisons 2024-02-23 13:25:31 -05:00
Kevin Newton 4016535404 [PRISM] Integrate new number parsing 2024-02-22 22:42:44 -05:00
Peter Zhu e65315a725 Extract imemo functions from gc.c into imemo.c 2024-02-22 11:35:09 -05:00
Nobuyoshi Nakada 01c7e16c0c Separate miniruby from dmyext.c 2024-02-21 23:37:20 +09:00
yui-knk e7ab5d891c Introduce NODE_REGX to manage regexp literal 2024-02-21 08:06:48 +09:00
Hiroshi SHIBATA cb9e0a4537
Don't exclude `test_gem_package_task.rb` explicitly.
3d4f5e7671 suppressed warnings.
2024-02-19 13:55:06 +09:00
Alan Wu fbe63047cb Fix PRISM build dependencies 2024-02-16 14:47:16 -05:00