summaryrefslogtreecommitdiff
path: root/transient_heap.c
Commit message (Collapse)AuthorAgeFilesLines
* `USE_RUBY_DEBUG_LOG` doesn't check `RUBY_DEVEL`Koichi Sasada2021-12-291-3/+1
| | | | | | | | `USE_RUBY_DEBUG_LOG` was only defined when `RUBY_DEVEL` is defined. This patch removes this dependency (`USE_RUBY_DEBUG_LOG` is defined independently from `RUBY_DEVEL`). Do not commit a patch which enables `USE_RUBY_DEBUG_LOG`.
* Suppress undef warnings for USE_RUBY_DEBUG_LOGNobuyoshi Nakada2021-12-251-1/+1
|
* Allow configuring TRANSIENT_HEAP_TOTAL_SIZEYuta Saito2021-12-101-0/+2
| | | | | | Some platforms have memory resource limits, but theap's memory area is too large for such situations. So allow configuring the size at build-time.
* Supress `warning: data argument not used by format string [-Wformat-extra-args]`Kazuhiro NISHIYAMA2021-10-201-2/+2
|
* cancel theap on multi-ractorsKoichi Sasada2020-12-071-67/+69
| | | | | | | 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.
* should stop other ractors on transient_heap_evacuateKoichi Sasada2020-11-251-0/+1
| | | | | | | | | transient_heap_evacuate() evacuates all living objects from theap to malloc mangaed memory. This evacuation can run in any ractors in parallel with other ractor's execution and it is danger. To stop such danger parallel execution, use rb_vm_barrier() to stop all other ractors.
* Fix USE_TRANSIENT_HEAP macro usage in hash.cCristian Greco2020-11-191-4/+4
| | | | Additionally fix some typos in transient heap.
* Suppress a warningKazuhiro NISHIYAMA2020-11-041-2/+2
| | | | | | | | | ``` transient_heap.c: In function ‘transient_heap_allocatable_header’: transient_heap.c:347:37: warning: comparison of integer expressions of different signedness: ‘int16_t’ {aka ‘short int’} and ‘long unsigned int’ [-Wsign-compare] 347 | TH_ASSERT(block->info.index <= TRANSIENT_HEAP_USABLE_SIZE); | ^~ ```
* Add `GC.auto_compact= true/false` and `GC.auto_compact`Aaron Patterson2020-11-021-13/+4
| | | | | | | | | | * `GC.auto_compact=`, `GC.auto_compact` can be used to control when compaction runs. Setting `auto_compact=` to true will cause compaction to occurr duing major collections. At the moment, compaction adds significant overhead to major collections, so please test first! [Feature #17176]
* Calculate transient heap block usable size at compile timeJacob Matthews2020-10-211-6/+5
|
* Unpoison THEAP header before readingAaron Patterson2020-09-281-0/+2
| | | | | Another ASAN fix. THEAP header is poisoned, so we need to un-poison before reading
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-83/+110
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* transient_heap_status_cstr() is used only for debuggingNobuyoshi Nakada2020-07-291-1/+3
|
* add debug output.Koichi Sasada2020-07-291-0/+19
|
* decouple internal.h headers卜部昌平2019-12-261-4/+10
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* rb_aligned_malloc can return NULL卜部昌平2019-11-011-0/+3
| | | | | | Looking at gc.c, rb_aligned_malloc contains `return NULL;` so it has to be taken care of. Note however that posix_memalign(3posix) does _not_ set errno.
* avoid overflow in integer multiplication卜部昌平2019-10-091-1/+10
| | | | | | | This changeset basically replaces `ruby_xmalloc(x * y)` into `ruby_xmalloc2(x, y)`. Some convenient functions are also provided for instance `rb_xmalloc_mul_add(x, y, z)` which allocates x * y + z byes.
* prefix ASAN related inline functions asan_Urabe, Shyouhei2019-05-231-9/+9
| | | | requested by Ko1.
* Rename rb_gc_new_location to rb_gc_locationAaron Patterson2019-05-181-2/+2
| | | | | The function will return new or existing locations depending on whether or not the object actually moved, so give it a more appropriate name.
* don't need to sweep rest.Koichi Sasada2019-05-161-1/+1
| | | | | | | | `transient_heap_evacuate()` disables GC using `rb_gc_disable()` to prohibt GC invocation because of new allocation for evacuated memory. However, `rb_gc_disable()` sweep all rest of unswept pages. We don't need to cancel lazy sweep so this patch introduce `rb_gc_disable_no_rest()` which doesn't cancel lazy sweep.
* unpoison header before touchingUrabe, Shyouhei2019-04-261-0/+3
| | | | | | This header is poisoned to detect unintentional buffer overrun. However in this (and forthcoming) function, we are intentionally looking at the header. We have to unpoison before anything.
* fix size of allocated memoryUrabe, Shyouhei2019-04-261-1/+1
| | | | | The size of `ptr` here is not the same as the variable `size`. We were counting the size of header twice.
* mark verify functions non-sanitizableUrabe, Shyouhei2019-04-261-0/+3
| | | | | These functions purposefully read from memory regions potentially not handled well. Should let sanitizers avoid checking them.
* __asan_region_is_poisoned takes void *Urabe, Shyouhei2019-04-261-1/+1
| | | | while heap->obj is a VALUE. A cast should be there.
* Add `GC.compact` again.tenderlove2019-04-201-0/+50
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-50/+0
| | | | | | For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-0/+50
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-50/+0
| | | | | | | | Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-0/+50
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename li_table->ar_table (and related names).ko12018-12-141-2/+2
| | | | | | | | | | | | | | | | | | | * internal.h: rename the following names: * li_table -> ar_table. "li" means linear (from linear search), but we use the word "array" (from data layout). * RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear. * rb_hash_array_* -> rb_hash_ar_table_*. * RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear. * RHASH_CLEAR() -> RHASH_ST_CLEAR(). * hash.c: rename "linear_" prefix functions to "ar_" prefix. * hash.c (linear_init_table): rename to ar_alloc_table. * debug_counter.h: rename obj_hash_array to obj_hash_ar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adopt sanitizer APIshyouhei2018-11-061-0/+14
| | | | | | | | These APIs are much like <valgrind/memcheck.h>. Use them to fine-grain annotate the usage of our memory. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce USE_TRANSIENT_HEAP to enable/disable theap.ko12018-11-011-0/+2
| | | | | | | | * include/ruby/ruby.h: intrdocue `USE_TRANSIENT_HEAP` macro to enable/disable transient heap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* explicit cast to void* required for %pshyouhei2018-10-311-8/+8
| | | | | | | | | No automatic type promotion is expected for variadic arguments. You have to do it by hand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces, expand tabs.svn2018-10-301-8/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_HASH. [Feature #14989]ko12018-10-301-6/+20
| | | | | | | | | | | | | | | | | * hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_STRUCT.ko12018-10-301-10/+10
| | | | | | | * struct.c: members memory can use theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_OBJECT.ko12018-10-301-6/+14
| | | | | | | | | | * variable.c: now instance variable space has theap supports. obj_ivar_heap_alloc() tries to acquire memory from theap. * debug_counter.h: add some counters for theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-0/+834
* transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). (re-commit of r65444) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e