summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2021-02-04Don't register non-heap allocated objectsAaron Patterson
`rb_define_const` can add objects as "mark objects". This is to make code like this work: https://github.com/ruby/ruby/blob/33d6e92e0c6eaf1308ce7108e653c53bb5fb106c/ext/etc/etc.c#L1201 ``` rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */ ``` sPasswd is a heap allocated object that is also a C global, so we can't move it (it needs to be pinned). However, we have many calls to `rb_define_const` that just pass in an integer like this: ``` rb_define_const(rb_cDBM, "WRITER", INT2FIX(O_RDWR|RUBY_DBM_RW_BIT)); ``` Non heap allocated objects like integers will never move, so there is no reason to waste time in the GC marking / pinning them. Notes: Merged: https://github.com/ruby/ruby/pull/4152
2021-02-01Use RCLASS_EXT macro instead of directly accessing ptrMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/4124
2021-02-01Add RCLASS_SUBCLASSES MacroMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/4124
2021-01-31Removed static assertion about size of `RVALUE`Nobuyoshi Nakada
It is unable where unaligned word access is disallowed and `double` is wider than pointers.
2021-01-31Narrowed down the condition to pack RValueNobuyoshi Nakada
Because of `double` in `RFloat`, `RValue` would be packed by `sizeof(double)` by default, on platforms where `double` is wider than `VALUE`. Size of `RValue` is multiple of 5 now.
2021-01-27[Fixes #17538] Fix assertion failure when rincgc is turned offPeter Zhu
Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/4064
2021-01-26Re-enable RGENGC_DEBUG for platforms with HAVE_VA_ARGS_MACROMatt Valentine-House
after this commit turned it off globally. 888cf28a7e3a07fc0a41688777a40910654005ad Co-authored-by: peterzhu2118 <peter@peterzhu.ca> Notes: Merged: https://github.com/ruby/ruby/pull/4073
2021-01-26Fix RGENGC CHECK MODE >= 4Matt Valentine-House
[A previous commit](b59077eecf912a16efefc0256f6e94a000ce3888) removes some macro definitions that are used when RGENGC_CHECK_MODE >=4 because they were using data stored against objspace, which is not ractor safe This commit reinstates those macro definitions, using the current ractor Co-authored-by: peterzhu2118 <peter@peterzhu.ca> Notes: Merged: https://github.com/ruby/ruby/pull/4074
2021-01-23gc.c: stop overflow check on emscripten buildYusuke Endoh
2021-01-22check is_incremental_marking() againKoichi Sasada
is_incremental_marking() can be changed after checking the flag without locking, especially on `GC.stress = true`.
2021-01-21Fix more assumptions about the read barrierAaron Patterson
This is a continuation of 0130e17a410d60a10e7041ce98748b8de6946971. We need to always use the read barrier
2021-01-21Always enabled read barrier even on GC.compactAaron Patterson
Some objects can survive the GC before compaction, but get collected in the second compaction. This means we could have objects reference T_MOVED during "free" in the second, compacting GC. If that is the case, we need to invalidate those "moved" addresses. Invalidation is done via read barrier, so we need to make sure the read barrier is active even during `GC.compact`. This also means we don't actually need to do one GC before compaction, we can just do the compaction and GC in one step.
2021-01-13fix ASAN errorsAaron Patterson
Notes: Merged: https://github.com/ruby/ruby/pull/4067
2021-01-09gc fix typo for the timer instruction for ARM64.David CARLIER
Notes: Merged: https://github.com/ruby/ruby/pull/4044
2021-01-06show more info about imemo_callcacheKoichi Sasada
Notes: Merged: https://github.com/ruby/ruby/pull/4030
2021-01-05[DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer
2021-01-05enable constant cache on ractorsKoichi Sasada
constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed. Notes: Merged: https://github.com/ruby/ruby/pull/4022
2020-12-29Stop managing valid class serialsTakashi Kokubun
`mjit_valid_class_serial_p` has no longer been used since b9007b6c548.
2020-12-28Adjusted styles [ci skip]Nobuyoshi Nakada
2020-12-26Fixed leaked global symbolsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4003
2020-12-25define RGENGC_DEBUG_ENABLED() as 0Koichi Sasada
on RUBY_DEVEL==0 and !HAVE_VA_ARGS_MACRO. gc_report() is always enabled on such configuration (maybe it is a bug) so disable RGENGC_DEBUG_ENABLED().
2020-12-23Use rb_init_identtable instead of direct use of rb_hashtype_identNobuyoshi Nakada
2020-12-22separate rb_ractor_pub from rb_ractor_tKoichi Sasada
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. Notes: Merged: https://github.com/ruby/ruby/pull/3943
2020-12-18finalizing should be checked before VM lockKoichi Sasada
2020-12-18Removed a moved local variableNobuyoshi Nakada
2020-12-18need to sync gc_finalize_deferredKoichi Sasada
gc_finalize_deferred() runs finalizers and it accesses objspace, so it need to sync.
2020-12-18Removed old GC.stat keys deprecated since 2.2Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3921
2020-12-18Removed old GC tuning environment variables deprecated since 2.1Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3921
2020-12-18acquire VM lock on gc_verify_internal_consistency()Koichi Sasada
There is a case to call this function without VM lock acquiring.
2020-12-18add explicit checkKoichi Sasada
To debug this issue: https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20201217T220004Z.fail.html.gz
2020-12-18gc_verify_internal_consistency() needs barrierKoichi Sasada
gc_verify_internal_consistency() accesses all slots (objects) so all ractors should stop before starting this function.
2020-12-17sync obj_to_id_tblKoichi Sasada
objspace->obj_to_id_tbl is a shared table so we need to synchronize it to access. Notes: Merged: https://github.com/ruby/ruby/pull/3924
2020-12-17reduce barrier counts for GC eventsKoichi Sasada
mark needs barrier (stop other ractors), but other GC events don't need barriers (maybe...). Notes: Merged: https://github.com/ruby/ruby/pull/3923
2020-12-17relax synchronization on WBKoichi Sasada
Current synchronization is too much on write barriers. Notes: Merged: https://github.com/ruby/ruby/pull/3918
2020-12-17add debug counters for gc start eventsKoichi Sasada
2020-12-17RGENGC_PROFILE=0Koichi Sasada
Enabled this flag, maybe accidentally.
2020-12-15Removed unneeded cast and use the real nameNobuyoshi Nakada
2020-12-11revert da3bca513f437b05b3953c3712ff48621fc5e008Koichi Sasada
It seems introduce critical problems. Now I could not find out the issue. http://ci.rvm.jp/results/trunk-test@ruby-sky1/3286048
2020-12-10ObjectSpace._id2ref should not support unshareableKoichi Sasada
ObjectSpace._id2ref(id) can return any objects even if they are unshareable, so this patch raises RangeError if it runs on multi-ractor mode and the found object is unshareable. Notes: Merged: https://github.com/ruby/ruby/pull/3878
2020-12-10Unpoison freelist to chainNobuyoshi Nakada
2020-12-10cache free pages per ractorKoichi Sasada
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. Notes: Merged: https://github.com/ruby/ruby/pull/3875
2020-12-10set min/maximum free slots relative to ractor cntKoichi Sasada
A program with multiple ractors can consume more objects per unit time, so this patch set minimum/maximum free_slots to relative to ractors count (upto 8). Notes: Merged: https://github.com/ruby/ruby/pull/3875
2020-12-10lazy sweep tries to collect 2048 slotsKoichi Sasada
Lazy sweep tries to collect free (unused) slots incrementally, and it only collect a few pages. This patch makes lazy sweep collects more objects (at least 2048 objects) and GC overhead of multi-ractor execution will be reduced. Notes: Merged: https://github.com/ruby/ruby/pull/3875
2020-12-09need the lock for debug checking.Koichi Sasada
Checking code (RGENGC_CHECK_MODE > 0) need a VM lock because it refers objspace.
2020-12-07need more lock in finalize_list()Koichi Sasada
Some data should be accessed in parallel so they should be protected by the lock.
2020-12-07RB_VM_LOCK_ENTER_NO_BARRIERKoichi Sasada
Write barrier requires VM lock because it accesses VM global bitmap but RB_VM_LOCK_ENTER() can invoke GC because another ractor can wait to invoke GC and RB_VM_LOCK_ENTER() is barrier point. This means that before protecting by a write barrier, GC can invoke. To prevent such situation, RB_VM_LOCK_ENTER_NO_BARRIER() is introduced. This lock primitive does not become GC barrier points.
2020-12-07skip assertion on multi-ractorKoichi Sasada
This assertion is not considerred on multi-ractor mdoe.
2020-12-07RB_EC_NEWOBJ_OFKoichi Sasada
NEWOBJ with current ec. Notes: Merged: https://github.com/ruby/ruby/pull/3842
2020-12-07per-ractor object allocationKoichi Sasada
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). Notes: Merged: https://github.com/ruby/ruby/pull/3842
2020-12-03Revert "Skip repeated scan of object during compaction"Aaron Patterson
This seems to be breaking the build for some reason. This command can reproduce it: `make yes-test-all TESTS=--repeat-count=20` This reverts commit 88bb1a672c49746972f4b15410fa92e9d237c43d.