Age | Commit message (Collapse) | Author |
|
d6c5a30cfdf658280338dbb8c8b17fab3190b928,a2d4e1cda68a49980a4f9f353f400efbde7e7884: [Backport #18392]
ObjectSpace::WeakMap#inspect: check if living object [Bug #18392]
---
gc.c | 29 +++++++++++++++++++++++------
test/ruby/test_weakmap.rb | 9 +++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
Fixed the check order in wmap_live_p [Bug #18392]
Check if the object is a pointer to heap before check the flag in
that object.
---
gc.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
|
|
0130e17a410d60a10e7041ce98748b8de6946971,32b7dcfb56a417c1d1c354102351fc1825d653bf,79cc566ab4cdf75f125ecf413a27d353a9756c08: [Backport #18394]
Always enabled read barrier even on GC.compact
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.
---
gc.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
Fix more assumptions about the read barrier
This is a continuation of 0130e17a410d60a10e7041ce98748b8de6946971. We
need to always use the read barrier
---
gc.c | 10 ----------
1 file changed, 10 deletions(-)
Make during_compacting flag in GC one bit
Commit c32218de1ba094223420a4ea017707f48d0009c5 turned during_compacting
flag to 2 bits to support the case when there is no write barrier. But
commit 32b7dcfb56a417c1d1c354102351fc1825d653bf changed compaction to
always enable the write barrier. This commit cleans up some of the
leftover code.
---
gc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
Fixed leaked global symbols
---
gc.c | 14 +++++++++-----
vm_insnhelper.c | 7 ++++---
vm_insnhelper.h | 2 +-
vm_sync.c | 4 ++--
vm_sync.h | 6 ++++--
5 files changed, 20 insertions(+), 13 deletions(-)
|
|
119697f61e2b2b157816a8aa33aada5863959900,4a627dbdfd1165022fa9e716ba845e937b03773d: [Backport #18014]
[Bug #18014] Fix rb_gc_force_recycle unmark before sweep
If we force recycle an object before the page is swept, we should clear
it in the mark bitmap. If we don't clear it in the bitmap, then during
sweeping we won't account for this free slot so the `free_slots` count
of the page will be incorrect.
---
gc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Bug #18014] Fix memory leak in GC when using Ractors
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.
---
gc.c | 116 +++++++++++++++++++++++++++-------------------------------
internal/gc.h | 6 +++
ractor.c | 3 ++
ractor_core.h | 5 +--
4 files changed, 64 insertions(+), 66 deletions(-)
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
|
|
skip marking for uninitialized imemo_env.
RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env
objects and marking it will cause critical error. This patch
skips marking on uninitialized imemo_env.
See: http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210329T183003Z.fail.html.gz
Shortest repro-code is provided by mame-san.
---
gc.c | 16 ++++++++++------
test/objspace/test_objspace.rb | 13 +++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
|
|
sync check_rvalue_consistency_force()
check_rvalue_consistency_force() uses is_pointer_to_heap() and
it should be synchronized with other ractors.
[Bug #17636]
---
gc.c | 149 ++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 76 insertions(+), 73 deletions(-)
|
|
969b824a0c7605e0e570631d967ad0de0c37d0bf,100e464bee46ae71ef048ed85a9bdd012935a3f7: [Backport #17599]
sync GC rest if needed
marking requires a barrier (stop all Ractors) and gc_enter() does it.
However, it doesn't check rest event which can start marking.
[Bug #17599]
---
gc.c | 3 +++
1 file changed, 3 insertions(+)
clear RVALUE on NEWOBJ event.
NEWOBJ event is called without clearing RVALUE values (v1, v2, v3).
This patch clear them before NEWOBJ tracepoint internal hook.
[Bug #17599]
---
gc.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
|
|
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.
|
|
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().
|
|
|
|
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
|
|
|
|
|
|
gc_finalize_deferred() runs finalizers and it accesses objspace,
so it need to sync.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3921
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3921
|
|
There is a case to call this function without VM lock acquiring.
|
|
To debug this issue:
https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20201217T220004Z.fail.html.gz
|
|
gc_verify_internal_consistency() accesses all slots (objects) so
all ractors should stop before starting this function.
|
|
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
|
|
mark needs barrier (stop other ractors), but other GC events don't need
barriers (maybe...).
Notes:
Merged: https://github.com/ruby/ruby/pull/3923
|
|
Current synchronization is too much on write barriers.
Notes:
Merged: https://github.com/ruby/ruby/pull/3918
|
|
|
|
Enabled this flag, maybe accidentally.
|
|
|
|
It seems introduce critical problems. Now I could not find
out the issue.
http://ci.rvm.jp/results/trunk-test@ruby-sky1/3286048
|
|
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
|
|
|
|
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
|
|
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
|
|
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
|
|
Checking code (RGENGC_CHECK_MODE > 0) need a VM lock because it
refers objspace.
|
|
Some data should be accessed in parallel so they should be protected
by the lock.
|
|
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.
|
|
This assertion is not considerred on multi-ractor mdoe.
|
|
NEWOBJ with current ec.
Notes:
Merged: https://github.com/ruby/ruby/pull/3842
|
|
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
|
|
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.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3843
|
|
When we allocate new pages, allocate them on the end of the linked list.
Then when we compact we can move things to the head of the list
Notes:
Merged: https://github.com/ruby/ruby/pull/3814
|
|
Incremental sweeping should sweep until we find a slot for objects to
use. `heap_increment` was adding a page to the heap even though we
would sweep immediately after.
Co-authored-by: John Hawthorn <john@hawthorn.email>
Notes:
Merged: https://github.com/ruby/ruby/pull/3837
|
|
|
|
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.
Notes:
Merged: https://github.com/ruby/ruby/pull/3822
|
|
read_barrier_handler() can cause SIGSEGV/BUS so it should show
the errors.
|
|
Unfortunately we couldn't see a C backtrace with the previous commit
http://ci.rvm.jp/results/trunk-random2@phosphorus-docker/3272697.
|
|
when GC.compact's SEGV handler is installed
|
|
Both explicit compaction routines (gc_compact and the verify references form)
need to clear the heap before executing compaction. Otherwise some
objects may not be alive, and we'll need the read barrier. The heap
must only contain *live* objects if we want to disable the read barrier
during explicit compaction.
The previous commit was missing the "clear the heap" phase from the
"verify references" explicit compaction function.
Fixes [Bug #17306]
|
|
This reverts commit 63ad55cd882e4010fe313d271af006a430b5ffa8.
Revert "Disable read barrier on explicit compaction request"
This reverts commit 490b57783d80f0c5f7882c66d9fb6aa02713c9a5.
|
|
Auto Compaction uses mprotect to implement a read barrier. mprotect can
only work on regions of memory that are a multiple of the OS page size.
Ruby's pages are a multiple of 4kb, but some platforms (like ppc64le)
don't have 4kb page sizes. This commit disables the features on those
platforms.
Fixes [Bug #17306]
|
|
|