diff options
author | Matt Valentine-House <[email protected]> | 2024-10-03 13:53:49 +0100 |
---|---|---|
committer | Matt Valentine-House <[email protected]> | 2024-10-03 21:20:09 +0100 |
commit | 8e7df4b7c674cf408fa570b9593811167bbff04a () | |
tree | fe143affd6601f6fc1a94d5a25084696ea8f660e /test/ruby | |
parent | b58a3645229b6c82c1f199fd948ec1fa97c0cc10 (diff) |
Rename size_pool -> heap
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://.com/ruby/ruby/pull/11771
-rw-r--r-- | test/ruby/test_gc.rb | 10 | ||||
-rw-r--r-- | test/ruby/test_gc_compact.rb | 14 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 4 |
3 files changed, 14 insertions, 14 deletions
@@ -226,7 +226,7 @@ class TestGc < Test::Unit::TestCase GC.stat_heap(0, stat_heap) GC.stat(stat) - GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i| EnvUtil.without_gc do GC.stat_heap(i, stat_heap) GC.stat(stat) @@ -248,7 +248,7 @@ class TestGc < Test::Unit::TestCase assert_equal stat_heap[:slot_size], GC.stat_heap(0)[:slot_size] assert_raise(ArgumentError) { GC.stat_heap(-1) } - assert_raise(ArgumentError) { GC.stat_heap(GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT]) } end def test_stat_heap_all @@ -259,7 +259,7 @@ class TestGc < Test::Unit::TestCase GC.stat_heap(0, stat_heap) GC.stat_heap(nil, stat_heap_all) - GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i| GC.stat_heap(nil, stat_heap_all) GC.stat_heap(i, stat_heap) @@ -538,7 +538,7 @@ class TestGc < Test::Unit::TestCase gc_count = GC.stat(:count) # Fill up all of the size pools to the init slots - GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i| capa = (GC.stat_heap(i, :slot_size) - GC::INTERNAL_CONSTANTS[:RVALUE_OVERHEAD] - (2 * RbConfig::SIZEOF["void*"])) / RbConfig::SIZEOF["void*"] while GC.stat_heap(i, :heap_eden_slots) < GC_HEAP_INIT_SLOTS Array.new(capa) @@ -558,7 +558,7 @@ class TestGc < Test::Unit::TestCase gc_count = GC.stat(:count) # Fill up all of the size pools to the init slots - GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i| capa = (GC.stat_heap(i, :slot_size) - GC::INTERNAL_CONSTANTS[:RVALUE_OVERHEAD] - (2 * RbConfig::SIZEOF["void*"])) / RbConfig::SIZEOF["void*"] while GC.stat_heap(i, :heap_eden_slots) < SIZES[i] Array.new(capa) @@ -283,7 +283,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_arrays_down_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10) @@ -305,7 +305,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_arrays_up_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10) @@ -329,7 +329,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_objects_between_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 60) @@ -361,7 +361,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_strings_up_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 30) @@ -382,7 +382,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_strings_down_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 30) @@ -402,7 +402,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_hashes_down_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 # AR and ST hashes are in the same size pool on 32 bit omit unless RbConfig::SIZEOF["uint64_t"] <= RbConfig::SIZEOF["void*"] @@ -425,7 +425,7 @@ class TestGCCompact < Test::Unit::TestCase end; end - def test_moving_objects_between_size_pools_keeps_shape_frozen_status # [Bug #19536] assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}") begin; @@ -662,8 +662,8 @@ CODE assert_equal(Encoding::UTF_8, "#{s}x".encoding) end - def test_string_interpolations_across_size_pools_get_embedded - omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 require 'objspace' base_slot_size = GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] |