aboutsummaryrefslogtreecommitdiffstats
path: root/ractor.c
Commit message (Collapse)AuthorAgeFilesLines
* Yet Another Ruby JIT!Jose Narvaez2021-10-201-2/+2
| | | | Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
* uJIT: Implement opt_getinlinecacheAlan Wu2021-10-201-0/+2
| | | | | | | | | | | | | | | | | * ujit: implement opt_getinlinecache Aggressively bet that writes to constants don't happen and invalidate all opt_getinlinecache blocks on any and all constant writes. Use alignment padding on block_t to track this assumption. No change to sizeof(block_t). * Fix compile warnings when not RUBY_DEBUG * Fix reversed condition * Switch to st_table to keep track of assumptions Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Use `RUBY_FUNCTION_NAME_STRING` for old Visual C++Nobuyoshi Nakada2021-10-201-3/+3
| | | | | Probably `__func__` is supported since Visual C++ 2015 (= 14.0, `_MSC_VER` = 1900).
* Cast to void pointer for `%p` in commented out code [ci skip]Nobuyoshi Nakada2021-10-201-4/+5
|
* Supress `warning: data argument not used by format string [-Wformat-extra-args]`Kazuhiro NISHIYAMA2021-10-201-4/+4
|
* Cast to void pointer to suppress -Wformat-pedantic in RUBY_DEBUG_LOGNobuyoshi Nakada2021-10-031-1/+1
|
* [Bug #18117] Fix Ractor race condition with GCPeter Zhu2021-08-241-2/+10
| | | | | | | | | | | | | | rb_objspace_reachable_objects_from requires that the GC not be active. Since the Ractor barrier is not executed for incremental sweeping, Ractor may call rb_objspace_reachable_objects_from after sweeping has started to share objects. This causes a crash that looks like the following: ``` <internal:ractor>:627: [BUG] rb_objspace_reachable_objects_from() is not supported while during_gc == true ``` Co-authored-by: Vinicius Stock <vinicius.stock@shopify.com>
* [Bug #18014] Fix memory leak in GC when using RactorsPeter Zhu2021-07-151-0/+3
| | | | | | | When a Ractor is removed, the freelist in the Ractor cache is not returned to the GC, leaving the freelist permanently lost. This commit recycles the freelist when the Ractor is destroyed, preventing a memory leak from occurring.
* Evacuate transient heap when enabling ractorseileencodes2021-06-231-0/+6
| | | | | | | | | | | If the GC has been disabled we need to re-enable it so we can evacuate the transient heap. Fixes https://bugs.ruby-lang.org/issues/17985 [Bug #17985] [ruby-core:104260] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Enable VM_ASSERT in --jit CIs (#4543)Takashi Kokubun2021-06-011-3/+3
|
* Fix some typos by spell checkerRyuta Kamizono2021-04-261-2/+2
|
* Moved locking VM to an atomic operationNobuyoshi Nakada2021-03-131-6/+2
|
* Make Ractor stdio belonging to the Ractor [Bug #17672]Nobuyoshi Nakada2021-03-071-9/+0
| | | | | Defer making ractor stdio until ractor started. Before ractor started, created objects belong to the caller ractor instead of the created ractor.
* Ractor.allocate should not be allowedKoichi Sasada2021-02-181-0/+2
| | | | | Ractor.allocate and Ractor#dup should not be allowed like Thread. [Bug #17642]
* fix Ractor.yield(obj, move: true)Koichi Sasada2021-01-221-15/+58
| | | | | | | | | | | | | | | | Ractor.yield(obj, move: true) and Ractor.select(..., yield_value: obj, move: true) tried to yield a value with move semantices, but if the trial is faild, the obj should not become a moved object. To keep this rule, `wait_moving` wait status is introduced. New yield/take process: (1) If a ractor tried to yield (move:true), make taking racotr's wait status `wait_moving` and make a moved object by `ractor_move(obj)` and wakeup taking ractor. (2) If a ractor tried to take a message from a ractor waiting fo yielding (move:true), wakeup the ractor and wait for (1).
* alen should be actions number on ractor_select()Koichi Sasada2021-01-221-7/+6
| | | | | alen was number of rs, but it should be actions number (taking ractors + receiving + yielding).
* use ractor_wakeup()Koichi Sasada2021-01-221-28/+27
| | | | Use ractor_wakeup() for same code.
* expose some C-APIs for ractorKoichi Sasada2021-01-061-0/+11
| | | | | | | | | | | | | expose some C-APIs to try to make ractor utilities on external gems. * add * rb_ractor_local_storage_value_lookup() to check availability * expose * rb_ractor_make_shareable() * rb_ractor_make_shareable_copy() * rb_proc_isolate() (not public) * rb_proc_isolate_bang() (not public) * rb_proc_ractor_make_shareable() (not public)
* introduce rb_ractor_atfork()Koichi Sasada2020-12-241-0/+18
| | | | to reset main ractor at fork().
* fix ractor-locking around rb_ractor_thread_list()Koichi Sasada2020-12-241-9/+21
| | | | | With locking a ractor, rb_ary_push() can call RB_VM_LOCK_ENTER() and it violates an assertion: should not acquire ractor-lock.
* Update rb_ractor_ensure_shareableNobuyoshi Nakada2020-12-231-2/+2
| | | | | * Fixed use of rb_ractor_shareable_p * Raise Ractor::IsolationError
* Changed shareable literal semantics [Feature #17397]Nobuyoshi Nakada2020-12-231-0/+11
| | | | | | When `literal`, check if the literal about to be assigned to a constant is ractor-shareable, otherwise raise `Ractor::Error` at runtime instead of `SyntaxError`.
* ruby_single_main_ractor should be clear before warnKoichi Sasada2020-12-231-2/+2
| | | | | rb_warn can produce T_HASA object and it should not use transient heap.
* Remove debugging codeMarc-Andre Lafortune2020-12-211-1/+0
|
* fix ractor's doc. [ci skip]Koichi Sasada2020-12-221-6/+14
|
* add Ractor#[]/#[]= for ractor local storageKoichi Sasada2020-12-221-0/+46
| | | | | This API is similar to plain old Thread#[]/Fiber#[] interface with symbol key.
* separate rb_ractor_pub from rb_ractor_tKoichi Sasada2020-12-221-43/+31
| | | | | | | | | separate some fields from rb_ractor_t to rb_ractor_pub and put it at the beggining of rb_ractor_t and declare it in vm_core.h so vm_core.h can access rb_ractor_pub fields. Now rb_ec_ractor_hooks() is a complete inline function and no MJIT related issue.
* TracePoint.new(&block) should be ractor-localKoichi Sasada2020-12-221-0/+8
| | | | | TracePoint should be ractor-local because the Proc can violate the Ractor-safe.
* Introduce Ractor::IsolationErrorKoichi Sasada2020-12-211-12/+9
| | | | | | | | | | | Ractor has several restrictions to keep each ractor being isolated and some operation such as `CONST="foo"` in non-main ractor raises an exception. This kind of operation raises an error but there is confusion (some code raises RuntimeError and some code raises NameError). To make clear we introduce Ractor::IsolationError which is raised when the isolation between ractors is violated.
* [DOC] Remove about FrozenError from Ractor::MovedObject [ci skip]Kazuhiro NISHIYAMA2020-12-211-9/+0
| | | | | Because unfreeze Ractor::MovedObject at https://github.com/ruby/ruby/commit/76e88480371469400346fca609efe67096813915
* should use owned_p instead of locked_pKoichi Sasada2020-12-211-1/+2
| | | | | It should raise an error if the same thread tris to call receive/receive_if.
* rename to rb_ractor_make_shareable_copy()Koichi Sasada2020-12-211-1/+1
| | | | from rb_ractor_make_copy_shareable().
* fix Ractor.make_shareable() with Class/ModuleKoichi Sasada2020-12-211-1/+1
| | | | | To check shareable-ness, rb_ractor_shareable_p() is needed for Class/Module objects isntead of checking flags.
* Tweak Ractor doc [doc] [ci skip]Marc-Andre Lafortune2020-12-191-4/+4
|
* Add documentation for Ractor (#3895)Victor Shepelev2020-12-191-0/+94
|
* unfreeze Ractor::MovedObjectKoichi Sasada2020-12-191-2/+0
| | | | | Matz prefers to unfreeze the class. [Feature #17401]
* add "copy: true" option for Ractor.make_shareableKoichi Sasada2020-12-191-0/+10
| | | | | | | | | | Ractor.make_shareable(obj) tries to make obj a shareable object by changing the attribute of obj and traversable objects from obj (mainly freeze them). "copy: true" option is more conservative approach by make deep copied object and make it sharable. It doesn't affect any existing objects.
* Use category: :experimental in warnings that are related to experimental ↵Jeremy Evans2020-12-181-2/+3
| | | | | | | | | features This adds rb_category_compile_warn in order to emit compiler warnings with categories. Note that Ripper currently ignores the category for these warnings, but by default it ignores the warnings completely, so this shouldn't matter.
* fix timing bugKoichi Sasada2020-12-171-7/+21
| | | | | | | | | ractor_sleep() can remain wait.status by interrupt, so that this patch handles more correctly. This patch fixed this kind of assertion failures: Assertion Failed: ../src/ractor.c:1332:ractor_yield_atexit:cr->sync.wait.status == wait_none
* Ractor#receive_if to receive only matched messagesKoichi Sasada2020-12-161-32/+272
| | | | | | | Instead of Ractor.receive, Ractor.receive_if can provide a pattern by a block and you can choose the receiving message. [Feature #17378]
* Fixed a suspicious comparisonNobuyoshi Nakada2020-12-131-1/+1
|
* re-layout rb_ractor_tKoichi Sasada2020-12-091-112/+112
| | | | separate synchronization data and ractor local data.
* fix Thread's interrupt and Ractor#take issueKoichi Sasada2020-12-071-2/+4
| | | | | | | | | Thread's interrupt set Ractor's wakeup_status as interrupted, but the status remains next Ractor communication API. This patch makes to ignore the previous interrupt state. [Bug #17366] Also this patch solves the Thread#kill and Ractor#take issues.
* fix decl of ruby_single_main_ractorKoichi Sasada2020-12-071-7/+0
| | | | | | | On windows, MJIT doesn't work without this patch because of the declaration of ruby_single_main_ractor. This patch fix this issue and move the definition of it from ractor.c to vm.c to locate near place of ruby_current_vm_ptr.
* per-ractor object allocationKoichi Sasada2020-12-071-1/+1
| | | | | | | | Now object allocation requires VM global lock to synchronize objspace. However, of course, it introduces huge overhead. This patch caches some slots (in a page) by each ractor and use cached slots for object allocation. If there is no cached slots, acquire the global lock and get new cached slots, or start GC (marking or lazy sweeping).
* cancel theap on multi-ractorsKoichi Sasada2020-12-071-14/+25
| | | | | | | accessing theap needs complicating synchronization but it reduce performance on multi-ractor mode. So simply stop using theap on multi-ractor mode. In future, theap should be replaced with more cleaver memory strategy.
* ruby_single_main_ractor for single ractor modeKoichi Sasada2020-12-071-3/+6
| | | | | | | | ruby_multi_ractor was a flag that indicates the interpreter doesn't make any additional ractors (single ractor mode). Instead of boolean flag, ruby_single_main_ractor pointer is introduced which keeps main ractor's pointer if single ractor mode. If additional ractors are created, ruby_single_main_ractor becomes NULL.
* fix indexKoichi Sasada2020-12-041-2/+3
| | | | | `i` should not be used here because `i` will be `alen` when jumped here by "goto restart".
* Skip checking Ractor recursive lockingTakashi Kokubun2020-12-021-3/+7
| | | | | for an MJIT worker thread. We can't do it because its GET_EC() returns NULL.
* should not use rb_str_modify(), tooKoichi Sasada2020-12-011-1/+1
| | | | | | Same as 8247b8edde, should not use rb_str_modify() here. https://bugs.ruby-lang.org/issues/17343#change-88858