summaryrefslogtreecommitdiff
path: root/gc/default.c
AgeCommit message (Collapse)Author
2024-11-25Place all non-default GC API behind USE_SHARED_GCMatt Valentine-House
So that it doesn't get included in the generated binaries for builds that don't support loading shared GC modules Co-Authored-By: Peter Zhu <peter@peterzhu.ca> Notes: Merged: https://github.com/ruby/ruby/pull/12149
2024-11-24Fix a build failure with muslEarlopain
``` compiling gc.c In file included from gc.c:80: /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map' 88 | struct prctl_mm_map { | ^~~~~~~~~~~~ In file included from gc.c:79: /usr/include/linux/prctl.h:134:8: note: originally defined here 134 | struct prctl_mm_map { | ^~~~~~~~~~~~ ``` The first include is not needed and is what causes this issue. Two other places in ruby exclusively use the sys import. See https://github.com/seccomp/libseccomp/issues/19 for a similar problem. Notes: Merged: https://github.com/ruby/ruby/pull/12154
2024-11-21Annotate anonymous mmapKunshan Wang
Use PR_SET_VMA_ANON_NAME to set human-readable names for anonymous virtual memory areas mapped by `mmap()` when compiled and run on Linux 5.17 or higher. This makes it convenient for developers to debug mmap. Notes: Merged: https://github.com/ruby/ruby/pull/12119
2024-11-14Expose GC.config[:implementation], to query the currently active GCMatt Valentine-House
And a default and readonly key to the GC.config hash that names the current GC implementation. This is provided by each implementation by the API function rb_gc_impl_active_gc_name Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-05Remove RGENGC_FORCE_MAJOR_GC flagMatt Valentine-House
[Bug #20762] Notes: Merged: https://github.com/ruby/ruby/pull/12002
2024-10-31[DOC] Fix typoskojix2
Notes: Merged: https://github.com/ruby/ruby/pull/11967 Merged-By: nobu <nobu@ruby-lang.org>
2024-10-25Remove useless freelist unlock/lock in gc_ref_updatePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11953
2024-10-23Move error handling for GC.stat_heap to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Make rb_gc_impl_stat_heap return a VALUE instead of size_tPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Move error handling for GC.stat to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Make rb_gc_impl_stat return a VALUE instead of size_tPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Move error handling for GC.latest_gc_info to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-21Don't clear out flags in rb_gc_obj_freePeter Zhu
If there's a crash after rb_gc_obj_free, it's hard to debug because the flags have been cleared out already. Notes: Merged: https://github.com/ruby/ruby/pull/11925
2024-10-18Move object processing in Process.warmup to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11904
2024-10-10Move return value of rb_gc_impl_config_set to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11870
2024-10-10Directly call rb_gc_impl_writebarrier_unprotectPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11857
2024-10-10Directly call rb_gc_impl_copy_finalizerPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11857
2024-10-03Rename size_pool -> heapMatt Valentine-House
Now that we've inlined the eden_heap into the size_pool, we should rename the size_pool to heap. So that Ruby contains multiple heaps, with different sized objects. The term heap as a collection of memory pages is more in memory management nomenclature, whereas size_pool was a name chosen out of necessity during the development of the Variable Width Allocation features of Ruby. The concept of size pools was introduced in order to facilitate different sized objects (other than the default 40 bytes). They wrapped the eden heap and the tomb heap, and some related state, and provided a reasonably simple way of duplicating all related concerns, to provide multiple pools that all shared the same structure but held different objects. Since then various changes have happend in Ruby's memory layout: * The concept of tomb heaps has been replaced by a global free pages list, with each page having it's slot size reconfigured at the point when it is resurrected * the eden heap has been inlined into the size pool itself, so that now the size pool directly controls the free_pages list, the sweeping page, the compaction cursor and the other state that was previously being managed by the eden heap. Now that there is no need for a heap wrapper, we should refer to the collection of pages containing Ruby objects as a heap again rather than a size pool Notes: Merged: https://github.com/ruby/ruby/pull/11771
2024-10-03Inline eden_heap into size_poolMatt Valentine-House
After the individual tomb_heaps were removed in favour of a global list of empty pages, the only instance of rb_heap_t left is the eden_heap within each size pool. This PR inlines the heap fields directly into rb_size_pool_t to remove indirection and remove the SIZE_POOL_EDEN_HEAP macro Notes: Merged: https://github.com/ruby/ruby/pull/11771
2024-10-03Remove unused macrosMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/11778
2024-10-02Fix compilation when RGENGC_CHECK_MODE >= 4Matt Valentine-House
the mark_function_data callback was moved from the ractor to the VM. Notes: Merged: https://github.com/ruby/ruby/pull/11770
2024-10-02Deduplicate RGENGC_CHECK_MODE into gc/gc.hPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11764
2024-10-01Replace heap_eden_total_slots with objspace_available_slotsPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11740
2024-09-30Move RUBY_INTERNAL_EVENT_FREEOBJ into GC implementationPeter Zhu
Instead of calling rb_gc_event_hook inside of rb_gc_obj_free, it should be up to the GC implementation to call the event. Notes: Merged: https://github.com/ruby/ruby/pull/11742
2024-09-30Remove unneeded prototype for objspace_available_slotsPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11739
2024-09-23Assert that objects in write barrier are not deadPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11654
2024-09-23Unpoison page->freelist before trying to assert on itKJ Tsanaktsidis
Otherwise trying to deref the pointer can cause an ASAN crash, even though the only reason we're dereferencing it is so that we can assert on it. Notes: Merged: https://github.com/ruby/ruby/pull/11660
2024-09-20Remove unneeded function prototype for rb_gc_impl_markPeter Zhu
2024-09-19Remove rb_gc_impl_initial_stress_setPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11646
2024-09-18Change rb_gc_impl_get_measure_total_time to return a boolPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11638
2024-09-17Make rb_gc_impl_set_measure_total_time return voidPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11637
2024-09-17Rename rb_gc_impl_get_profile_total_time to rb_gc_impl_get_total_timePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11639
2024-09-17Change rb_gc_impl_get_profile_total_time to return unsigned long longPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11639
2024-09-17Use unsigned long long for marking and sweeping timePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11639
2024-09-16Move desired_compaction_pages_i inside of GC_CAN_COMPILE_COMPACTIONPeter Zhu
Fixes the following warning on WebAssembly: gc/default.c:7306:1: warning: unused function 'desired_compaction_pages_i' [-Wunused-function] desired_compaction_pages_i(struct heap_page *page, void *data) Notes: Merged: https://github.com/ruby/ruby/pull/11607
2024-09-16ASAN unpoison whole heap page after adding to size poolPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11623
2024-09-16Don't return inside of asan_unpoisoning_objectPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11623
2024-09-16Replace with asan_unpoisoning_objectPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11623
2024-09-12Move checks for heap traversal to rb_gc_mark_weakPeter Zhu
If we are during heap traversal, we don't want to call rb_gc_impl_mark_weak. This commit moves that check from rb_gc_impl_mark_weak to rb_gc_mark_weak. Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-12Move special const checks to rb_gc_mark_weakPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-09ASAN unlock freelist in size_pool_add_pagePeter Zhu
2024-09-09ASAN unlock freelist in gc_sweep_stepPeter Zhu
2024-09-09Add keys to GC.stat and fix testsPeter Zhu
This adds keys heap_empty_pages and heap_allocatable_slots to GC.stat.
2024-09-09Implement global allocatable slots and empty pagesPeter Zhu
[Bug #20710] This commit introduces moves allocatable slots and empty pages from per size pool to global. This allows size pools to grow globally and allows empty pages to move between size pools. For the benchmark in [Bug #20710], this signficantly improves performance: Before: new_env 2.563 (± 0.0%) i/s - 26.000 in 10.226703s new_rails_env 0.293 (± 0.0%) i/s - 3.000 in 10.318960s After: new_env 3.781 (±26.4%) i/s - 37.000 in 10.302374s new_rails_env 0.911 (± 0.0%) i/s - 9.000 in 10.049337s In the headline benchmarks on yjit-bench, we see the performance is basically on-par with before, with ruby-lsp being signficantly faster and activerecord and erubi-rails being slightly slower: -------------- ----------- ---------- ----------- ---------- -------------- ------------- bench master (ms) stddev (%) branch (ms) stddev (%) branch 1st itr master/branch activerecord 452.2 0.3 479.4 0.4 0.96 0.94 chunky-png 1157.0 0.4 1172.8 0.1 0.99 0.99 erubi-rails 905.4 0.3 967.2 0.4 0.94 0.94 hexapdf 3566.6 0.6 3553.2 0.3 1.03 1.00 liquid-c 88.9 0.9 89.0 1.3 0.98 1.00 liquid-compile 93.4 0.9 89.9 3.5 1.01 1.04 liquid-render 224.1 0.7 227.1 0.5 1.00 0.99 lobsters 1052.0 3.5 1067.4 2.1 0.99 0.99 mail 197.1 0.4 196.5 0.5 0.98 1.00 psych-load 2960.3 0.1 2988.4 0.8 1.00 0.99 railsbench 2252.6 0.4 2255.9 0.5 0.99 1.00 rubocop 262.7 1.4 270.1 1.8 1.02 0.97 ruby-lsp 275.4 0.5 242.0 0.3 0.97 1.14 sequel 98.4 0.7 98.3 0.6 1.01 1.00 -------------- ----------- ---------- ----------- ---------- -------------- -------------
2024-09-09Replace heap_allocated_pages with rb_darray_sizePeter Zhu
2024-09-09Switch sorted list of pages in the GC to a darrayPeter Zhu
2024-09-04Remove unused allocatable_pages field in objspacePeter Zhu
2024-09-03Fix indentation broken in 53eaa67 [ci skip]Peter Zhu
2024-09-03Unpoision the object in rb_gc_impl_garbage_object_pPeter Zhu
2024-09-03Move responsibility of heap walking into RubyPeter Zhu
This commit removes the need for the GC implementation to implement heap walking and instead Ruby will implement it. Notes: Merged: https://github.com/ruby/ruby/pull/11511