Skip to content

Commit 735b0bf

Browse files
committed
Put parallel sweep impl behind --enable-parallel-sweep configure option
1 parent 8bacf20 commit 735b0bf

6 files changed

Lines changed: 114 additions & 24 deletions

File tree

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,6 +4293,16 @@ AC_ARG_ENABLE(debug-env,
42934293
AS_HELP_STRING([--enable-debug-env], [enable RUBY_DEBUG environment variable]),
42944294
[AC_SUBST(ENABLE_DEBUG_ENV, yes)])
42954295

4296+
AC_ARG_ENABLE(parallel-sweep,
4297+
AS_HELP_STRING([--enable-parallel-sweep],
4298+
[enable background sweep thread in the default GC [[disabled by default]]]),
4299+
[parallel_sweep=$enableval], [parallel_sweep=no])
4300+
AS_IF([test "x$parallel_sweep" = xyes], [
4301+
RUBY_APPEND_OPTIONS(CPPFLAGS, -DUSE_PARALLEL_SWEEP=1)
4302+
], [
4303+
RUBY_APPEND_OPTIONS(CPPFLAGS, -DUSE_PARALLEL_SWEEP=0)
4304+
])
4305+
42964306
AS_IF([test "$gnumake" = yes], [ NULLCMD=: ], [
42974307
AC_MSG_CHECKING([for safe null command for ${MAKE-make}])
42984308
mkdir conftest.dir

gc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ rb_objspace_free(void *objspace)
980980

981981
void rb_gc_impl_parallel_sweep_start(void *objspace_ptr);
982982

983+
#if USE_PARALLEL_SWEEP
983984
void
984985
rb_gc_parallel_sweep_start(void)
985986
{
@@ -989,6 +990,7 @@ rb_gc_parallel_sweep_start(void)
989990
#endif
990991
rb_gc_impl_parallel_sweep_start(rb_gc_get_objspace());
991992
}
993+
#endif
992994

993995
size_t
994996
rb_gc_obj_slot_size(VALUE obj)
@@ -2484,7 +2486,7 @@ rb_gc_obj_free_concurrency_safe_vm_weak_references(VALUE obj)
24842486
ASSUME(!RB_SPECIAL_CONST_P(obj));
24852487
bool result = obj_free_object_id(obj, false);
24862488

2487-
if (RB_UNLIKELY(rb_obj_gen_fields_p(obj))) {
2489+
if (rb_obj_gen_fields_p(obj)) {
24882490
bool freed_generic = rb_free_generic_ivar(obj);
24892491
if (!freed_generic) result = false;
24902492
}
@@ -2503,14 +2505,14 @@ rb_gc_obj_free_concurrency_safe_vm_weak_references(VALUE obj)
25032505
return result;
25042506
}
25052507

2506-
bool
2508+
void
25072509
rb_gc_obj_free_vm_weak_references(VALUE obj)
25082510
{
25092511
ASSUME(!RB_SPECIAL_CONST_P(obj));
25102512

25112513
obj_free_object_id(obj, true);
25122514

2513-
if (RB_UNLIKELY(rb_obj_gen_fields_p(obj))) {
2515+
if (rb_obj_gen_fields_p(obj)) {
25142516
rb_free_generic_ivar(obj);
25152517
}
25162518

@@ -2538,7 +2540,6 @@ rb_gc_obj_free_vm_weak_references(VALUE obj)
25382540
default:
25392541
break;
25402542
}
2541-
return true;
25422543
}
25432544

25442545
/*
@@ -4402,7 +4403,7 @@ vm_weak_table_frozen_strings_foreach(VALUE *str, void *data)
44024403
}
44034404

44044405
if (retval == ST_DELETE) {
4405-
FL_UNSET(*str, RSTRING_FSTR);
4406+
FL_UNSET_RAW(*str, RSTRING_FSTR);
44064407
}
44074408

44084409
return retval;

0 commit comments

Comments
 (0)