diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2023-01-10 17:58:45 +0000 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-01-13 10:31:35 -0500 |
commit | bb5fddd0709e17360eef343b986cd5a61ea2598c (patch) | |
tree | 01fa8706d87c5563b4c82a649248794752065bdd /test | |
parent | fc7f8520337be9513d984f67c9ef98ef85d03d0f (diff) |
Remove MIN_PRE_ALLOC_SIZE from Strings.
This optimisation is no longer helpful now that we use VWA to allocate
strings in larger size pools where they can be embedded.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6965
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 1ece47b18a..e34fd116c9 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -661,6 +661,27 @@ 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] + small_obj_size = (base_slot_size / 2) + large_obj_size = base_slot_size * 2 + + a = "a" * small_obj_size + b = "a" * large_obj_size + + res = "#{a}, #{b}" + dump_res = ObjectSpace.dump(res) + dump_orig = ObjectSpace.dump(a) + new_slot_size = Integer(dump_res.match(/"slot_size":(\d+)/)[1]) + orig_slot_size = Integer(dump_orig.match(/"slot_size":(\d+)/)[1]) + + assert_match(/"embedded":true/, dump_res) + assert_operator(new_slot_size, :>, orig_slot_size) + end + def test_count a = S("hello world") assert_equal(5, a.count(S("lo"))) |