aboutsummaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* [ci skip] comment for commit be1bbd5b7d40ad863ab35097765d3754726bbd54卜部昌平2023-12-081-5/+105
|
* Thread specific storage APIsKoichi Sasada2023-12-081-0/+40
| | | | | | | | | | | | | | | | | | | | | This patch introduces thread specific storage APIs for tools which use `rb_internal_thread_event_hook` APIs. * `rb_internal_thread_specific_key_create()` to create a tool specific thread local storage key and allocate the storage if not available. * `rb_internal_thread_specific_set()` sets a data to thread and tool specific storage. * `rb_internal_thread_specific_get()` gets a data in thread and tool specific storage. Note that `rb_internal_thread_specific_get|set(thread_val, key)` can be called without GVL and safe for async signal and safe for multi-threading (native threads). So you can call it in any internal thread event hooks. Further more you can call it from other native threads. Of course `thread_val` should be living while accessing the data from this function. Note that you should not forget to clean up the set data.
* Add `RUBY_REFERENCES`Nobuyoshi Nakada2023-11-301-1/+2
| | | | | Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that auto-indent works well.
* Prefix `REF_EDGE` and `REFS_LIST_PTR` with `RUBY_`Nobuyoshi Nakada2023-11-301-2/+2
| | | | Also move `struct` so that `typedef`-ed names can be used.
* Refactor and fix the GVL instrumentation APIJean Boussier2023-11-271-2/+5
| | | | | | | | | | | | This entirely changes how it is tested. Rather than to use counters we now record the timeline of events with associated threads which makes it much easier to assert that certains events are only preceded by a specific event, and makes it much easier to debug unexpected timelines. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com> Co-Authored-By: JP Camara <jp@jpcamara.com> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* Constify `RUBY_REFERENCES_START` tablesNobuyoshi Nakada2023-11-261-1/+1
|
* GVL Instrumentation: pass thread->self as part of event dataJean Boussier2023-11-131-1/+3
| | | | | | | | | | | | | | | | | | | Context: https://github.com/ivoanjo/gvl-tracing/pull/4 Some hooks may want to collect data on a per thread basis. Right now the only way to identify the concerned thread is to use `rb_nativethread_self()` or similar, but even then because of the thread cache or MaNy, two distinct Ruby threads may report the same native thread id. By passing `thread->self`, hooks can use it as a key to store the metadata. NB: Most hooks are executed outside the GVL, so such data collection need to use a thread-safe data-structure, and shouldn't use the reference in other ways from inside the hook. They must also either pin that value or handle compaction.
* [DOC] Update comment for `DECIMAL_SIZE_OF_BITS`Nobuyoshi Nakada2023-11-111-1/+3
|
* TypedData_Make_Struct0: cast RTYPEDDATA_GET_DATA return pointerJean Boussier2023-11-081-1/+1
| | | | | | | | | | | | | Fixes: ``` /usr/local/ruby/include/ruby-3.3.0+0/ruby/internal/core/rtypeddata.h:467:33: error: invalid conversion from ‘void*’ to ‘parser_t*’ [-fpermissive] 467 | (sval) = RTYPEDDATA_GET_DATA(result); \ | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ | | | void* ```
* Implement embedded TypedData objectsPeter Zhu2023-11-071-2/+37
| | | | | | | | This commit adds a new flag RUBY_TYPED_EMBEDDABLE that allows the data of a TypedData object to be embedded after the object itself. This will improve cache locality and allow us to save the 8 byte data pointer. Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
* [DOC] Update the document for `FilePathStringValue`Nobuyoshi Nakada2023-11-021-2/+4
|
* [Feature #10602] Add new API rb_profile_thread_frames()Daisuke Aritomo2023-10-311-0/+19
| | | | | | | | | | | | | | | | | | | | Add a new API rb_profile_thread_frames(), which is essentialy a per-thread version of rb_profile_frames(). While the original rb_profile_frames() always returns results about the current active thread obtained by GET_EC(), this new API takes a Thread to be profiled as an argument. This should come in handy when profiling I/O-bound programs such as webapps, since this new API allows us to learn about Threads performing I/O (which do not have the GVL). Profiling worker threads (such as Sidekiq workers) may be another application. Implements [Feature #10602] Co-authored-by: Mike Perham <mike@perham.net>
* M:N thread scheduler for RactorsKoichi Sasada2023-10-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduce M:N thread scheduler for Ractor system. In general, M:N thread scheduler employs N native threads (OS threads) to manage M user-level threads (Ruby threads in this case). On the Ruby interpreter, 1 native thread is provided for 1 Ractor and all Ruby threads are managed by the native thread. From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means 1 Ruby thread has 1 native thread. M:N scheduler change this strategy. Because of compatibility issue (and stableness issue of the implementation) main Ractor doesn't use M:N scheduler on default. On the other words, threads on the main Ractor will be managed with 1:1 thread scheduler. There are additional settings by environment variables: `RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor. Note that non-main ractors use the M:N scheduler without this configuration. With this configuration, single ractor applications run threads on M:1 thread scheduler (green threads, user-level threads). `RUBY_MAX_CPU=n` specifies maximum number of native threads for M:N scheduler (default: 8). This patch will be reverted soon if non-easy issues are found. [Bug #19842]
* [DOC] Fix description for `rb_postponed_job_register_one()`Daisuke Aritomo2023-10-041-3/+3
| | | | | | The current documentation for `rb_postponed_job_register_one()` is explaining the differences with itself, where it should be explaining the differences with `rb_postponed_job_register()`.
* Fix documentation for rb_warn() and friendsBenoit Daloze2023-09-291-11/+11
| | | | | * rb_warn() does not warn if $VERBOSE is nil, the "always" is wrong. * Talk about $VERBOSE and not -W since $VERBOSE can be changed at runtime.
* [DOC] Missing comment markersNobuyoshi Nakada2023-09-272-2/+2
|
* Fix comment for rb_enc_str_new [ci skip]John Hawthorn2023-09-161-1/+1
|
* memory_view: Avoid using bit fieldSutou Kouhei2023-09-091-2/+2
| | | | | | | | | | Bit field's memory layout is implementation-defined. See also: https://wiki.sei.cmu.edu/confluence/display/c/EXP11-C.+Do+not+make+assumptions+regarding+the+layout+of+structures+with+bit-fields If memory layout is implementation-defined, it's difficult to use from FFI library such as Ruby-FFI.
* Document that thread event hooks are called without the GVLJean Boussier2023-09-071-1/+33
| | | | Except for the `RESUMED` event.
* Expose `rb_process_status_wait` and hide `rb_process_status_waitv`. (#8316)Samuel Williams2023-08-291-0/+9
|
* Restore `HAVE_RB_IO_T` macro for compatibility with `kgio`, `unicorn`, etc. ↵Samuel Williams2023-08-281-0/+1
| | | | (#8286)
* workaround clang-17 -Wc2x-extensions卜部昌平2023-08-251-0/+12
| | | | cf: https://github.com/llvm/llvm-project/commit/874217f99b99ab3c9026dc3b7bd84cd2beebde6e
* YJIT: Move ROBJECT_OFFSET_* to yjit.c (#8157)Takashi Kokubun2023-08-021-7/+0
|
* support `rescue` event for TracePointKoichi Sasada2023-08-011-0/+1
| | | | fix [Feature #19572]
* Resurrect rb_reg_prepare_re C APITakashi Kokubun2023-07-271-0/+21
| | | | | | | | Existing strscan releases rely on this C API. It means that the current Ruby master doesn't work if your Gemfile.lock has strscan unless it's locked to 3.0.7, which is not released yet. To fix it, let's not remove the C API we've exposed to users.
* Add function rb_reg_onig_matchPeter Zhu2023-07-271-7/+11
| | | | | | rb_reg_onig_match performs preparation, error handling, and cleanup for matching a regex against a string. This reduces repetitive code and removes the need for StringScanner to access internal data of regex.
* Check if macros are defined before usingNobuyoshi Nakada2023-07-241-4/+4
| | | | Assume macros with the same prefix would be defined together.
* RString NULL ptr check only when RUBY_DEBUGNobuyoshi Nakada2023-07-241-7/+3
| | | | | Since edf01d4e82d8e44ee30ec41fbcb7f802bc8b8c5d, fake string treats NULL as an empty string.
* Embed struct rmatch into GC slot (#8097)Kunshan Wang2023-07-201-8/+6
|
* Move `posix_signal` declaration internal with prefix `ruby_`Nobuyoshi Nakada2023-07-171-6/+0
|
* Remove RARRAY_CONST_PTR_TRANSIENTPeter Zhu2023-07-131-22/+2
| | | | RARRAY_CONST_PTR now does the same things as RARRAY_CONST_PTR_TRANSIENT.
* Remove RARRAY_PTR_USE_TRANSIENTPeter Zhu2023-07-131-12/+2
| | | | RARRAY_PTR_USE now does the same things as RARRAY_PTR_USE_TRANSIENT.
* Remove rb_array_ptr_use_{start,end}Peter Zhu2023-07-131-52/+5
|
* [Feature #19730] Remove transient heapPeter Zhu2023-07-131-88/+0
|
* [Feature #19757] Add new API `rb_data_define`Nobuyoshi Nakada2023-07-131-0/+14
|
* Store object age in a bitmapMatt Valentine-House2023-07-132-41/+15
| | | | | | | | | | | | | | | | | | Closes [Feature #19729] Previously 2 bits of the flags on each RVALUE are reserved to store the number of GC cycles that each object has survived. This commit introduces a new bit array on the heap page, called age_bits, to store that information instead. This patch still reserves one of the age bits in the flags (the old FL_PROMOTED0 bit, now renamed FL_PROMOTED). This is set to 0 for young objects and 1 for old objects, and is used as a performance optimisation for the write barrier. Fetching the age_bits from the heap page and doing the required math to calculate if the object was old or not would slow down the write barrier. So we keep this bit synced in the flags for fast access.
* Remove reference to USE_RINCGCMatt Valentine-House2023-07-041-12/+0
| | | | | | This compile time flag was removed in https://github.com/ruby/ruby/pull/7313 This commit cleans up some related dead code.
* Fix memory leak when copying ST tablesPeter Zhu2023-06-291-0/+2
| | | | | | | | | | | | | | | | | st_copy allocates a st_table, which is not needed for hashes since it is allocated by VWA and embedded, so this causes a memory leak. The following script demonstrates the issue: ```ruby 20.times do 100_000.times do {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9} end puts `ps -o rss= -p #{$$}` end ```
* Use `rb_reg_nth_defined` instead of `rb_match_nth_defined`Nobuyoshi Nakada2023-06-271-5/+0
|
* Remove taint and untrusted flags (#7958)Nobuyoshi Nakada2023-06-191-9/+2
| | | | | | | | | | * Make TAINT and UNTRUSTED flags zero These flags do nothing already, and should break nothing. * Remove TAINT and UNTRUSTED macros same as functions These macros had been defined to use with `#ifdef`, but should not be used anymore.
* Fixes [Bug #19732]. Add missing stdint.h header to event.h.Peter Arato2023-06-171-0/+4
|
* [DOC] Should use `NULL` instead of zeroNobuyoshi Nakada2023-06-121-8/+8
| | | | | | | Since no type information is available for variadic arguments, 0 is passed as `int` without promoting to pointer. On platforms where `sizeof(int) < sizeof(void*)`, the terminator argument may be read together with an adjoining word, and may not be found.
* Optimize `Regexp#dup` and `Regexp.new(/RE/)`Nobuyoshi Nakada2023-06-091-0/+2
| | | | | When copying from another regexp, copy already built `regex_t` instead of re-compiling its source.
* Add deprecations for public `struct rb_io` members. (#7916)Samuel Williams2023-06-081-12/+27
| | | * Add deprecations for public struct rb_io members.
* Unify length field for embedded and heap strings (#7908)Peter Zhu2023-06-061-43/+13
| | | | | | | | * Unify length field for embedded and heap strings The length field is of the same type and position in RString for both embedded and heap allocated strings, so we can unify it. * Remove RSTRING_EMBED_LEN
* Expose `enum rb_io_event` flags without `_t` suffix. (#7887)Samuel Williams2023-06-011-2/+4
|
* Drop `_t` suffix from struct names. (#7886)Samuel Williams2023-06-012-12/+12
| | | POSIX reserves `_t` suffix in types.
* Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams2023-06-011-1/+34
| | | This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility.
* Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui2023-06-012-43/+125
| | | | | | | | | This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
* Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams2023-05-302-125/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>