summaryrefslogtreecommitdiff
path: root/ractor_core.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix format-pedantic warningsNobuyoshi Nakada2022-07-281-1/+1
|
* Add "rb_" prefixes to toplevel enum definitionsYusuke Endoh2022-07-221-4/+4
| | | | ... as per ko1's request.
* Move enum definitions out of struct definitionYusuke Endoh2022-07-221-39/+42
|
* cleanup by `RUBY_DEBUG_LOG2` and `VM_ASSERT`Koichi Sasada2022-05-241-12/+5
|
* rename thread internal namingKoichi Sasada2022-04-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Now GVL is not process *Global* so this patch try to use another words. * `rb_global_vm_lock_t` -> `struct rb_thread_sched` * `gvl->owner` -> `sched->running` * `gvl->waitq` -> `sched->readyq` * `rb_gvl_init` -> `rb_thread_sched_init` * `gvl_destroy` -> `rb_thread_sched_destroy` * `gvl_acquire` -> `thread_sched_to_running` # waiting -> ready -> running * `gvl_release` -> `thread_sched_to_waiting` # running -> waiting * `gvl_yield` -> `thread_sched_yield` * `GVL_UNLOCK_BEGIN` -> `THREAD_BLOCKING_BEGIN` * `GVL_UNLOCK_END` -> `THREAD_BLOCKING_END` * removed * `rb_ractor_gvl` * `rb_vm_gvl_destroy` (not used) There are GVL functions such as `rb_thread_call_without_gvl()` yet but I don't have good name to replace them. Maybe GVL stands for "Greate Valuable Lock" or something like that.
* internal/ractor.h: AddedYusuke Endoh2022-03-301-2/+0
| | | | Currently it has only one function prototype.
* ractor.c: Add a helper function to ensure the context is a main ractorYusuke Endoh2022-03-301-0/+2
|
* Prefix ccan headers (#4568)Nobuyoshi Nakada2022-03-301-2/+2
| | | | | | | | | | | | | * Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
* Move rb_ractor_p definitionS.H2021-10-041-0/+1
|
* Remove printf family from the mjit headerNobuyoshi Nakada2021-09-111-5/+9
| | | | | Linking printf family functions makes mjit objects to link unnecessary code.
* [Bug #18014] Fix memory leak in GC when using RactorsPeter Zhu2021-07-151-4/+1
| | | | | | | 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.
* Fix trivial -Wundef warningsBenoit Daloze2021-05-041-1/+1
| | | | | | * See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
* fix Ractor.yield(obj, move: true)Koichi Sasada2021-01-221-0/+1
| | | | | | | | | | | | | | | | 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).
* shareable_constant_value: experimental_copyKoichi Sasada2020-12-241-0/+2
| | | | | | | "experimental_everything" makes the assigned value, it means the assignment change the state of assigned value. "experimental_copy" tries to make a deep copy and make copyied object sharable.
* introduce rb_ractor_atfork()Koichi Sasada2020-12-241-0/+1
| | | | to reset main ractor at fork().
* add Ractor#[]/#[]= for ractor local storageKoichi Sasada2020-12-221-0/+1
| | | | | This API is similar to plain old Thread#[]/Fiber#[] interface with symbol key.
* separate rb_ractor_pub from rb_ractor_tKoichi Sasada2020-12-221-7/+14
| | | | | | | | | 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/+2
| | | | | TracePoint should be ractor-local because the Proc can violate the Ractor-safe.
* Ractor#receive_if to receive only matched messagesKoichi Sasada2020-12-161-2/+6
| | | | | | | Instead of Ractor.receive, Ractor.receive_if can provide a pattern by a block and you can choose the receiving message. [Feature #17378]
* revert da3bca513f437b05b3953c3712ff48621fc5e008Koichi Sasada2020-12-111-1/+0
| | | | | | | It seems introduce critical problems. Now I could not find out the issue. http://ci.rvm.jp/results/trunk-test@ruby-sky1/3286048
* cache free pages per ractorKoichi Sasada2020-12-101-0/+1
| | | | | | | Per ractor method cache (GH-#3842) only cached 1 page and this patch caches several pages to keep at least 512 free slots if available. If you increase the number of cached free slots, all cached slots will be collected when the GC is invoked.
* re-layout rb_ractor_tKoichi Sasada2020-12-091-9/+10
| | | | separate synchronization data and ractor local data.
* per-ractor object allocationKoichi Sasada2020-12-071-0/+5
| | | | | | | | 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).
* ruby_single_main_ractor for single ractor modeKoichi Sasada2020-12-071-3/+1
| | | | | | | | 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.
* ractor local storage C-APIKoichi Sasada2020-12-011-2/+10
| | | | | | | | | | | | | | | | | | | | | | To manage ractor-local data for C extension, the following APIs are defined. * rb_ractor_local_storage_value_newkey * rb_ractor_local_storage_value * rb_ractor_local_storage_value_set * rb_ractor_local_storage_ptr_newkey * rb_ractor_local_storage_ptr * rb_ractor_local_storage_ptr_set At first, you need to create a key of storage by rb_ractor_local_(value|ptr)_newkey(). For ptr storage, it accepts the type of storage, how to mark and how to free with ractor's lifetime. rb_ractor_local_storage_value/set are used to access a VALUE and rb_ractor_local_storage_ptr/set are used to access a pointer. random.c uses this API.
* Use opaque struct pointer than voidNobuyoshi Nakada2020-11-271-1/+3
|
* per-ractor Random::DEFAULTKoichi Sasada2020-11-271-0/+2
| | | | | | | | | | Random generators are not Ractor-safe, so we need to prepare per-ractor default random genearators. This patch set `Random::DEFAULT = Randm` (not a Random instance, but the Random class) and singleton methods like `Random.rand()` use a per-ractor random generator. [Feature #17322]
* Move the declaration into the functionKazuhiro NISHIYAMA2020-11-181-0/+4
| | | | instead of 'do not call it directly.' comment.
* fix public interfaceKoichi Sasada2020-11-181-0/+306
To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)