[DOC] Tweaks for GC.config

This commit is contained in:
BurdetteLamar 2025-08-06 17:59:15 -05:00 committed by Peter Zhu
parent c914389ae8
commit 62b5fe8984

85
gc.rb
View file

@ -258,71 +258,58 @@ module GC
# call-seq: # call-seq:
# GC.config -> hash # GC.config -> hash
# GC.config(hash) -> hash # GC.config(hash_to_merge) -> merged_hash
# #
# Sets or gets information about the current \GC config. # This method is expected to be defined, useful, and well-behaved
# only in the CRuby implementation.
# #
# Configuration parameters are \GC implementation-specific and may change # Sets or gets information about the current \GC configuration.
# without notice.
# #
# This method can be called without parameters to retrieve the current config # With no argument given, returns a hash containing the configuration:
# as a +Hash+ with +Symbol+ keys.
# #
# This method can also be called with a +Hash+ argument to assign values to # GC.config
# valid config keys. Config keys missing from the passed +Hash+ will be left # # => {rgengc_allow_full_mark: true, implementation: "default"}
# unmodified.
# #
# If a key/value pair is passed to this function that does not correspond to # With argument +hash_to_merge+ given,
# a valid config key for the \GC implementation being used, no config will be # merges that hash into the stored configuration hash;
# updated, the key will be present in the returned Hash, and its value will # ignores unknown hash keys;
# be +nil+. This is to facilitate easy migration between \GC implementations. # returns the implementation-specific configuration hash (see below):
# #
# In both call-seqs, the return value of <code>GC.config</code> will be a +Hash+ # GC.config(rgengc_allow_full_mark: false)
# containing the most recent full configuration, i.e., all keys and values # # => {rgengc_allow_full_mark: false}
# defined by the specific \GC implementation being used. In the case of a # GC.config
# config update, the return value will include the new values being updated. # # => {rgengc_allow_full_mark: false, implementation: "default"}
# GC.config(foo: 'bar')
# # => {rgengc_allow_full_mark: false}
# GC.config
# # => {rgengc_allow_full_mark: false, implementation: "default"}
# #
# This method is only expected to work on CRuby. # <b>All-Implementations Configuration</b>
# #
# === \GC Implementation independent values # The single read-only entry for all implementations is:
# #
# The <code>GC.config</code> hash can also contain keys that are global and # - +implementation+:
# read-only. These keys are not specific to any one \GC library implementation # the string name of the implementation;
# and attempting to write to them will raise +ArgumentError+. # for the Ruby default implementation, <tt>'default'</tt>.
# #
# There is currently only one global, read-only key: # <b>Implementation-Specific Configuration</b>
# #
# [implementation] # A \GC implementation maintains its own implementation-specific configuration.
# Returns a +String+ containing the name of the currently loaded \GC library,
# if one has been loaded using +RUBY_GC_LIBRARY+, and "default" in all other
# cases
# #
# === \GC Implementation specific values # For Ruby's default implementation the single entry is:
# #
# \GC libraries are expected to document their own configuration. Valid keys # - +rgengc_allow_full_mark+:
# for Ruby's default \GC implementation are: # Controls whether the \GC is allowed to run a full mark (young & old objects):
# #
# [rgengc_allow_full_mark] # - +true+ (default): \GC interleaves major and minor collections.
# Controls whether the \GC is allowed to run a full mark (young & old objects). # - +false+: \GC does not initiate a full marking cycle unless
# explicitly directed by user code;
# see GC.start.
# #
# When +true+, \GC interleaves major and minor collections. This is the default. \GC # Setting this parameter to +false+ disables young-to-old promotion .
# will function as intended. # For performance reasons, we recommended warming up the application using Process.warmup
#
# When +false+, the \GC will never trigger a full marking cycle unless
# explicitly requested by user code. Instead, only a minor mark will run—
# only young objects will be marked. When the heap space is exhausted, new
# pages will be allocated immediately instead of running a full mark.
#
# A flag will be set to notify that a full mark has been
# requested. This flag is accessible using
# <code>GC.latest_gc_info(:need_major_by)</code>
#
# The user can trigger a major collection at any time using
# <code>GC.start(full_mark: true)</code>
#
# When +false+, Young to Old object promotion is disabled. For performance
# reasons, it is recommended to warm up an application using +Process.warmup+
# before setting this parameter to +false+. # before setting this parameter to +false+.
#
def self.config hash = nil def self.config hash = nil
return Primitive.gc_config_get unless hash return Primitive.gc_config_get unless hash