Skip to content

Commit 0cddf41

Browse files
committed
Put parallel sweep impl behind --enable-parallel-sweep configure option
1 parent 6aa8309 commit 0cddf41

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
@@ -4292,6 +4292,16 @@ AC_ARG_ENABLE(debug-env,
42924292
AS_HELP_STRING([--enable-debug-env], [enable RUBY_DEBUG environment variable]),
42934293
[AC_SUBST(ENABLE_DEBUG_ENV, yes)])
42944294

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

gc.c

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

998998
void rb_gc_impl_parallel_sweep_start(void *objspace_ptr);
999999

1000+
#if USE_PARALLEL_SWEEP
10001001
void
10011002
rb_gc_parallel_sweep_start(void)
10021003
{
@@ -1006,6 +1007,7 @@ rb_gc_parallel_sweep_start(void)
10061007
#endif
10071008
rb_gc_impl_parallel_sweep_start(rb_gc_get_objspace());
10081009
}
1010+
#endif
10091011

10101012
size_t
10111013
rb_gc_obj_slot_size(VALUE obj)
@@ -2437,7 +2439,7 @@ rb_gc_obj_free_concurrency_safe_vm_weak_references(VALUE obj)
24372439
ASSUME(!RB_SPECIAL_CONST_P(obj));
24382440
bool result = obj_free_object_id(obj, false);
24392441

2440-
if (RB_UNLIKELY(rb_obj_gen_fields_p(obj))) {
2442+
if (rb_obj_gen_fields_p(obj)) {
24412443
bool freed_generic = rb_free_generic_ivar(obj);
24422444
if (!freed_generic) result = false;
24432445
}
@@ -2456,14 +2458,14 @@ rb_gc_obj_free_concurrency_safe_vm_weak_references(VALUE obj)
24562458
return result;
24572459
}
24582460

2459-
bool
2461+
void
24602462
rb_gc_obj_free_vm_weak_references(VALUE obj)
24612463
{
24622464
ASSUME(!RB_SPECIAL_CONST_P(obj));
24632465

24642466
obj_free_object_id(obj, true);
24652467

2466-
if (RB_UNLIKELY(rb_obj_gen_fields_p(obj))) {
2468+
if (rb_obj_gen_fields_p(obj)) {
24672469
rb_free_generic_ivar(obj);
24682470
}
24692471

@@ -2491,7 +2493,6 @@ rb_gc_obj_free_vm_weak_references(VALUE obj)
24912493
default:
24922494
break;
24932495
}
2494-
return true;
24952496
}
24962497

24972498
/*
@@ -4382,7 +4383,7 @@ vm_weak_table_frozen_strings_foreach(VALUE *str, void *data)
43824383
}
43834384

43844385
if (retval == ST_DELETE) {
4385-
FL_UNSET(*str, RSTRING_FSTR);
4386+
FL_UNSET_RAW(*str, RSTRING_FSTR);
43864387
}
43874388

43884389
return retval;

0 commit comments

Comments
 (0)