Revert "Fix transient heap mode"

This reverts commit 87253d047ce35e7836b6f97edbb4f819879a3b25.

Revert "Implement `Process.warmup`"

This reverts commit ba6ccd871442f55080bffd53e33678c0726787d2.
This commit is contained in:
Aaron Patterson 2023-04-04 12:58:56 -07:00
parent e5de0fe108
commit 8525603c72
No known key found for this signature in database
GPG Key ID: 953170BCB4FFAFC6
7 changed files with 0 additions and 110 deletions

View File

@ -35,13 +35,6 @@ Note: We're only listing outstanding class updates.
The class use equality semantic to lookup keys like a regular hash,
but it doesn't hold strong references on the keys. [[Feature #18498]]
* Process.warnup
* Notify the Ruby virtual machine that the boot sequence is finished,
and that now is a good time to optimize the application. This is useful
for long running applications. The actual optimizations performed are entirely
implementation specific and may change in the future without notice. [[Feature #18885]
## Stdlib updates
The following default gems are updated.

View File

@ -11024,9 +11024,7 @@ process.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
process.$(OBJEXT): {$(VPATH)}thread_native.h
process.$(OBJEXT): {$(VPATH)}util.h
process.$(OBJEXT): {$(VPATH)}vm_core.h
process.$(OBJEXT): {$(VPATH)}vm_debug.h
process.$(OBJEXT): {$(VPATH)}vm_opts.h
process.$(OBJEXT): {$(VPATH)}vm_sync.h
ractor.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
ractor.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
ractor.$(OBJEXT): $(CCAN_DIR)/list/list.h

47
gc.c
View File

@ -9833,26 +9833,6 @@ garbage_collect_with_gvl(rb_objspace_t *objspace, unsigned int reason)
}
}
static int
gc_promote_object_i(void *vstart, void *vend, size_t stride, void *data)
{
rb_objspace_t *objspace = &rb_objspace;
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_ZOMBIE:
break;
default:
if (!RVALUE_OLD_P(v) && !RVALUE_WB_UNPROTECTED(v)) {
RVALUE_AGE_SET_OLD(objspace, v);
}
}
}
return 0;
}
static VALUE
gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE immediate_mark, VALUE immediate_sweep, VALUE compact)
{
@ -9880,33 +9860,6 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE
return Qnil;
}
void
rb_gc_prepare_heap(void)
{
gc_start_internal(NULL, Qtrue, Qtrue, Qtrue, Qtrue, Qtrue);
/* Flush any postponed jobs.
* Transient heap uses postponed jobs to mark things, so we need to
* give it a chance to finish what it was doing. */
rb_postponed_job_flush(GET_VM());
/* The transient heap need to be evacuated before we promote objects.
* First put the transient heap in marking mode so that we can
* evacuate everything. Then evacuate everything. Then finish up
* marking mode so that the transient heap is in the right mode
* for the next GC. */
rb_transient_heap_start_marking(true);
rb_transient_heap_evacuate();
rb_transient_heap_finish_marking();
/* Finally, promote everyone to old gen, but don't let the GC run
* while we iterate over the heap. */
VALUE gc_disabled = rb_gc_disable_no_rest();
rb_objspace_each_objects(gc_promote_object_i, NULL);
if (gc_disabled != Qtrue) rb_gc_enable();
rb_transient_heap_verify();
}
static int
gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
{

View File

@ -214,7 +214,6 @@ extern VALUE *ruby_initial_gc_stress_ptr;
extern int ruby_disable_gc;
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
void ruby_mimfree(void *ptr);
void rb_gc_prepare_heap(void);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
VALUE rb_objspace_gc_enable(struct rb_objspace *);
VALUE rb_objspace_gc_disable(struct rb_objspace *);

View File

@ -115,7 +115,6 @@ int initgroups(const char *, rb_gid_t);
#include "ruby/thread.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "vm_sync.h"
#include "ruby/ractor.h"
/* define system APIs */
@ -8511,37 +8510,6 @@ static VALUE rb_mProcUID;
static VALUE rb_mProcGID;
static VALUE rb_mProcID_Syscall;
/*
* call-seq:
* Process.warmup -> true
*
* Notify the Ruby virtual machine that the boot sequence is finished,
* and that now is a good time to optimize the application. This is useful
* for long running applications.
*
* This method is expected to be called at the end of the application boot.
* If the application is deployed using a pre-forking model, +Process.warmup+
* should be called in the original process before the first fork.
*
* The actual optimizations performed are entirely implementation specific
* and may change in the future without notice.
*
* On CRuby, +Process.warmup+:
*
* * Perform a major GC.
* * Compacts the heap.
* * Promotes all surviving objects to the old generation.
*/
static VALUE
proc_warmup(VALUE _)
{
RB_VM_LOCK_ENTER();
rb_gc_prepare_heap();
RB_VM_LOCK_LEAVE();
return Qtrue;
}
/*
* Document-module: Process
@ -8659,8 +8627,6 @@ InitVM_process(void)
rb_define_module_function(rb_mProcess, "getpriority", proc_getpriority, 2);
rb_define_module_function(rb_mProcess, "setpriority", proc_setpriority, 3);
rb_define_module_function(rb_mProcess, "warmup", proc_warmup, 0);
#ifdef HAVE_GETPRIORITY
/* see Process.setpriority */
rb_define_const(rb_mProcess, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));

View File

@ -1,11 +0,0 @@
require_relative '../../spec_helper'
describe "Process.warmup" do
ruby_version_is "3.3" do
# The behavior is entirely implementation dependant.
# Other implementations are free to just make it a noop
it "is implemented" do
Process.warmup.should == true
end
end
end

View File

@ -4,7 +4,6 @@ require 'test/unit'
require 'tempfile'
require 'timeout'
require 'rbconfig'
require 'objspace'
class TestProcess < Test::Unit::TestCase
RUBY = EnvUtil.rubybin
@ -2680,11 +2679,4 @@ EOS
end
end;
end if Process.respond_to?(:_fork)
def test_warmup_promote_all_objects_to_oldgen
obj = Object.new
refute_includes(ObjectSpace.dump(obj), '"old":true')
Process.warmup
assert_includes(ObjectSpace.dump(obj), '"old":true')
end
end