Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't call hash tombstone compaction from GC compaction #13206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions set.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ set_replace_ref(st_data_t *key, st_data_t argp, int existing)
}

static void
set_compact(void *ptr)
set_update_references(void *ptr)
{
struct set_object *sobj = ptr;
set_compact_table(&sobj->table);
set_foreach_with_replace(&sobj->table, set_foreach_replace, set_replace_ref, 0);
}

Expand All @@ -192,7 +191,7 @@ static const rb_data_type_t set_data_type = {
.dmark = set_mark,
.dfree = set_free,
.dsize = set_size,
.dcompact = set_compact,
.dcompact = set_update_references,
},
.flags = RUBY_TYPED_EMBEDDABLE | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE
};
Expand Down
13 changes: 13 additions & 0 deletions test/ruby/test_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,19 @@ def test_reset
assert_equal(klass.new([a]), set, klass.name)
}
end

def test_set_gc_compact_does_not_allocate
assert_in_out_err([], <<-"end;", [], [])
def x
s = Set.new
s << Object.new
s
end

x
GC.compact
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah mmtk, doesn't have GC.compact:

    1) Failure:
  TC_Set#test_set_gc_compact_does_not_allocate [/Users/runner/work/ruby/ruby/src/test/ruby/test_set.rb:869]:
  pid 52362 exit 1
  | -:8:in '<main>': compact() function is unimplemented on this machine (NotImplementedError)
  | 	from -:8:in '<main>'
  .

Sorry for suggesting that change :/

end;
end
end

class TC_Enumerable < Test::Unit::TestCase
Expand Down
Loading