Skip to content

Commit

Permalink
added faster losing patches from trunk. only gave 10% speedup. somewh…
Browse files Browse the repository at this point in the history
…at disappointing.
  • Loading branch information
Stefan Kaes authored and skaes committed Nov 14, 2012
1 parent 4c31fd9 commit 4f8648e
Show file tree
Hide file tree
Showing 7 changed files with 789 additions and 40 deletions.
65 changes: 33 additions & 32 deletions patches/ruby/1.9.3/head/railsexpress/01-railsbench-gc.patch
@@ -1,8 +1,8 @@
diff --git a/configure.in b/configure.in
index 1d727e4..0c2b661 100644
index b006a01..af5acc4 100644
--- a/configure.in
+++ b/configure.in
@@ -2465,6 +2465,10 @@ if test "$EXEEXT" = .exe; then
@@ -2473,6 +2473,10 @@ if test "$EXEEXT" = .exe; then
AC_SUBST(EXECUTABLE_EXTS)
fi

Expand All @@ -14,7 +14,7 @@ index 1d727e4..0c2b661 100644
dnl build section {

diff --git a/gc.c b/gc.c
index e65d0ec..551e4c1 100644
index e65d0ec..169dfab 100644
--- a/gc.c
+++ b/gc.c
@@ -96,6 +96,15 @@ ruby_gc_params_t initial_params = {
Expand Down Expand Up @@ -262,7 +262,7 @@ index e65d0ec..551e4c1 100644
/*
* call-seq:
* GC.enable -> true or false
@@ -940,6 +1062,454 @@ rb_gc_disable(void)
@@ -940,6 +1062,455 @@ rb_gc_disable(void)
return old ? Qtrue : Qfalse;
}

Expand Down Expand Up @@ -597,6 +597,7 @@ index e65d0ec..551e4c1 100644
+ rb_objspace_t *objspace = &rb_objspace;
+ VALUE filename, str, include_classnames = Qnil;
+ char *fname = NULL;
+ char *klass = NULL;
+ FILE* f = NULL;
+ size_t i = 0;
+
Expand Down Expand Up @@ -717,7 +718,7 @@ index e65d0ec..551e4c1 100644
VALUE rb_mGC;

void
@@ -1011,6 +1581,12 @@ allocate_sorted_heaps(rb_objspace_t *objspace, size_t next_heaps_length)
@@ -1011,6 +1582,12 @@ allocate_sorted_heaps(rb_objspace_t *objspace, size_t next_heaps_length)
static void
assign_heap_slot(rb_objspace_t *objspace)
{
Expand All @@ -730,15 +731,15 @@ index e65d0ec..551e4c1 100644
RVALUE *p, *pend, *membase;
struct heaps_slot *slot;
size_t hi, lo, mid;
@@ -1072,6 +1648,7 @@ assign_heap_slot(rb_objspace_t *objspace)
@@ -1072,6 +1649,7 @@ assign_heap_slot(rb_objspace_t *objspace)
if (lomem == 0 || lomem > p) lomem = p;
if (himem < pend) himem = pend;
heaps_used++;
+ heap_size += objs;

while (p < pend) {
p->as.free.flags = 0;
@@ -1127,7 +1704,7 @@ initial_expand_heap(rb_objspace_t *objspace)
@@ -1127,7 +1705,7 @@ initial_expand_heap(rb_objspace_t *objspace)
static void
set_heaps_increment(rb_objspace_t *objspace)
{
Expand All @@ -747,7 +748,7 @@ index e65d0ec..551e4c1 100644

if (next_heaps_length == heaps_used) {
next_heaps_length++;
@@ -1160,6 +1737,22 @@ rb_during_gc(void)
@@ -1160,6 +1738,22 @@ rb_during_gc(void)

#define RANY(o) ((RVALUE*)(o))

Expand All @@ -770,7 +771,7 @@ index e65d0ec..551e4c1 100644
VALUE
rb_newobj(void)
{
@@ -1191,9 +1784,11 @@ rb_newobj(void)
@@ -1191,9 +1785,11 @@ rb_newobj(void)

MEMZERO((void*)obj, RVALUE, 1);
#ifdef GC_DEBUG
Expand All @@ -783,7 +784,7 @@ index e65d0ec..551e4c1 100644
GC_PROF_INC_LIVE_NUM;

return obj;
@@ -1660,6 +2255,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
@@ -1660,6 +2256,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
{
register RVALUE *obj = RANY(ptr);

Expand All @@ -796,7 +797,7 @@ index e65d0ec..551e4c1 100644
goto marking; /* skip */

again:
@@ -1670,6 +2271,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
@@ -1670,6 +2272,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
obj->as.basic.flags |= FL_MARK;
objspace->heap.live_num++;

Expand All @@ -809,7 +810,7 @@ index e65d0ec..551e4c1 100644
marking:
if (FL_TEST(obj, FL_EXIVAR)) {
rb_mark_generic_ivar(ptr);
@@ -2012,6 +2619,25 @@ free_unused_heaps(rb_objspace_t *objspace)
@@ -2012,6 +2620,25 @@ free_unused_heaps(rb_objspace_t *objspace)
}
}

Expand All @@ -835,7 +836,7 @@ index e65d0ec..551e4c1 100644
static void
slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
{
@@ -2019,14 +2645,23 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
@@ -2019,14 +2646,23 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
RVALUE *p, *pend;
RVALUE *free = freelist, *final = deferred_final_list;
int deferred;
Expand All @@ -859,7 +860,7 @@ index e65d0ec..551e4c1 100644
p->as.free.flags = T_ZOMBIE;
RDATA(p)->dfree = 0;
}
@@ -2036,6 +2671,10 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
@@ -2036,6 +2672,10 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
final_num++;
}
else {
Expand All @@ -870,7 +871,7 @@ index e65d0ec..551e4c1 100644
add_freelist(objspace, p);
free_num++;
}
@@ -2043,13 +2682,22 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
@@ -2043,13 +2683,22 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
else if (BUILTIN_TYPE(p) == T_ZOMBIE) {
/* objects to be finalized */
/* do nothing remain marked */
Expand All @@ -894,7 +895,7 @@ index e65d0ec..551e4c1 100644
objspace->heap.free_num > objspace->heap.do_heap_free) {
RVALUE *pp;

@@ -2060,6 +2708,8 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
@@ -2060,6 +2709,8 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
sweep_slot->limit = final_num;
freelist = free; /* cancel this page from freelist */
unlink_heap_slot(objspace, sweep_slot);
Expand All @@ -903,7 +904,7 @@ index e65d0ec..551e4c1 100644
}
else {
objspace->heap.free_num += free_num;
@@ -2072,6 +2722,10 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
@@ -2072,6 +2723,10 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
RUBY_VM_SET_FINALIZER_INTERRUPT(th);
}
}
Expand All @@ -914,7 +915,7 @@ index e65d0ec..551e4c1 100644
}

static int
@@ -2092,6 +2746,21 @@ ready_to_gc(rb_objspace_t *objspace)
@@ -2092,6 +2747,21 @@ ready_to_gc(rb_objspace_t *objspace)
static void
before_gc_sweep(rb_objspace_t *objspace)
{
Expand All @@ -936,7 +937,7 @@ index e65d0ec..551e4c1 100644
freelist = 0;
objspace->heap.do_heap_free = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.65);
objspace->heap.free_min = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.2);
@@ -2111,8 +2780,13 @@ before_gc_sweep(rb_objspace_t *objspace)
@@ -2111,8 +2781,13 @@ before_gc_sweep(rb_objspace_t *objspace)
static void
after_gc_sweep(rb_objspace_t *objspace)
{
Expand All @@ -950,7 +951,7 @@ index e65d0ec..551e4c1 100644
if (objspace->heap.free_num < objspace->heap.free_min) {
set_heaps_increment(objspace);
heaps_increment(objspace);
@@ -2125,6 +2799,29 @@ after_gc_sweep(rb_objspace_t *objspace)
@@ -2125,6 +2800,29 @@ after_gc_sweep(rb_objspace_t *objspace)
malloc_increase = 0;

free_unused_heaps(objspace);
Expand Down Expand Up @@ -980,7 +981,7 @@ index e65d0ec..551e4c1 100644
}

static int
@@ -2158,9 +2855,11 @@ rest_sweep(rb_objspace_t *objspace)
@@ -2158,9 +2856,11 @@ rest_sweep(rb_objspace_t *objspace)

static void gc_marks(rb_objspace_t *objspace);

Expand All @@ -992,15 +993,15 @@ index e65d0ec..551e4c1 100644
int res;
INIT_GC_PROF_PARAMS;

@@ -2182,7 +2881,6 @@ gc_lazy_sweep(rb_objspace_t *objspace)
@@ -2182,7 +2882,6 @@ gc_lazy_sweep(rb_objspace_t *objspace)
GC_PROF_TIMER_STOP(Qfalse);
return res;
}
- after_gc_sweep(objspace);
}
else {
if (heaps_increment(objspace)) {
@@ -2190,6 +2888,18 @@ gc_lazy_sweep(rb_objspace_t *objspace)
@@ -2190,6 +2889,18 @@ gc_lazy_sweep(rb_objspace_t *objspace)
return TRUE;
}
}
Expand All @@ -1019,7 +1020,7 @@ index e65d0ec..551e4c1 100644

gc_marks(objspace);

@@ -2198,6 +2908,10 @@ gc_lazy_sweep(rb_objspace_t *objspace)
@@ -2198,6 +2909,10 @@ gc_lazy_sweep(rb_objspace_t *objspace)
set_heaps_increment(objspace);
}

Expand All @@ -1030,15 +1031,15 @@ index e65d0ec..551e4c1 100644
GC_PROF_SWEEP_TIMER_START;
if(!(res = lazy_sweep(objspace))) {
after_gc_sweep(objspace);
@@ -2209,6 +2923,7 @@ gc_lazy_sweep(rb_objspace_t *objspace)
@@ -2209,6 +2924,7 @@ gc_lazy_sweep(rb_objspace_t *objspace)
GC_PROF_SWEEP_TIMER_STOP;

GC_PROF_TIMER_STOP(Qtrue);
+
return res;
}

@@ -2435,9 +3150,15 @@ gc_marks(rb_objspace_t *objspace)
@@ -2435,9 +3151,15 @@ gc_marks(rb_objspace_t *objspace)
rb_thread_t *th = GET_THREAD();
GC_PROF_MARK_TIMER_START;

Expand All @@ -1055,7 +1056,7 @@ index e65d0ec..551e4c1 100644

SET_STACK_END;

@@ -2477,11 +3198,15 @@ gc_marks(rb_objspace_t *objspace)
@@ -2477,11 +3199,15 @@ gc_marks(rb_objspace_t *objspace)
}
}
GC_PROF_MARK_TIMER_STOP;
Expand All @@ -1071,7 +1072,7 @@ index e65d0ec..551e4c1 100644
INIT_GC_PROF_PARAMS;

if (GC_NOTIFY) printf("start garbage_collect()\n");
@@ -2497,15 +3222,31 @@ garbage_collect(rb_objspace_t *objspace)
@@ -2497,15 +3223,31 @@ garbage_collect(rb_objspace_t *objspace)

rest_sweep(objspace);

Expand Down Expand Up @@ -1103,7 +1104,7 @@ index e65d0ec..551e4c1 100644
return TRUE;
}

@@ -2994,6 +3735,39 @@ rb_gc_call_finalizer_at_exit(void)
@@ -2994,6 +3736,39 @@ rb_gc_call_finalizer_at_exit(void)
rb_objspace_call_finalizer(&rb_objspace);
}

Expand Down Expand Up @@ -1143,7 +1144,7 @@ index e65d0ec..551e4c1 100644
static void
rb_objspace_call_finalizer(rb_objspace_t *objspace)
{
@@ -3307,6 +4081,49 @@ count_objects(int argc, VALUE *argv, VALUE os)
@@ -3307,6 +4082,49 @@ count_objects(int argc, VALUE *argv, VALUE os)
return hash;
}

Expand Down Expand Up @@ -1193,7 +1194,7 @@ index e65d0ec..551e4c1 100644
/*
* call-seq:
* GC.count -> Integer
@@ -3599,6 +4416,28 @@ Init_GC(void)
@@ -3599,6 +4417,28 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "stat", gc_stat, -1);
rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);

Expand Down Expand Up @@ -1222,7 +1223,7 @@ index e65d0ec..551e4c1 100644
rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
rb_define_singleton_method(rb_mProfiler, "enabled?", gc_profile_enable_get, 0);
rb_define_singleton_method(rb_mProfiler, "enable", gc_profile_enable, 0);
@@ -3612,6 +4451,9 @@ Init_GC(void)
@@ -3612,6 +4452,9 @@ Init_GC(void)
rb_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1);
rb_define_module_function(rb_mObSpace, "garbage_collect", rb_gc_start, 0);

Expand Down
@@ -1,5 +1,5 @@
diff --git a/gc.c b/gc.c
index 551e4c1..1d707fd 100644
index 169dfab..629a73a 100644
--- a/gc.c
+++ b/gc.c
@@ -1322,6 +1322,34 @@ rb_gc_log_file(int argc, VALUE *argv, VALUE self)
Expand Down Expand Up @@ -38,10 +38,10 @@ index 551e4c1..1d707fd 100644
* GC.log String => String
*
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 6dec838..559088a 100644
index 927b536..9da266e 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -431,6 +431,8 @@ void rb_gc_call_finalizer_at_exit(void);
@@ -425,6 +425,8 @@ void rb_gc_call_finalizer_at_exit(void);
VALUE rb_gc_enable(void);
VALUE rb_gc_disable(void);
VALUE rb_gc_start(void);
Expand Down
@@ -1,5 +1,5 @@
diff --git a/gc.c b/gc.c
index 1d707fd..9eeeb4d 100644
index 629a73a..8ab287e 100644
--- a/gc.c
+++ b/gc.c
@@ -270,7 +270,6 @@ getrusage_time(void)
Expand All @@ -10,7 +10,7 @@ index 1d707fd..9eeeb4d 100644
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
#endif
@@ -1538,6 +1537,24 @@ rb_gc_time()
@@ -1539,6 +1538,24 @@ rb_gc_time()
#endif
}

Expand All @@ -35,7 +35,7 @@ index 1d707fd..9eeeb4d 100644
VALUE rb_mGC;

void
@@ -4451,6 +4468,7 @@ Init_GC(void)
@@ -4452,6 +4469,7 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "allocated_size", rb_gc_allocated_size, 0);
rb_define_singleton_method(rb_mGC, "num_allocations", rb_gc_num_allocations, 0);
rb_define_singleton_method(rb_mGC, "heap_slots", rb_gc_heap_slots, 0);
Expand Down
@@ -1,5 +1,5 @@
diff --git a/gc.c b/gc.c
index 9eeeb4d..06e6655 100644
index 8ab287e..a77ef2c 100644
--- a/gc.c
+++ b/gc.c
@@ -1029,6 +1029,7 @@ ruby_xfree(void *x)
Expand Down
Expand Up @@ -298,7 +298,7 @@ index eb0be9f..a8721c4 100644
rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0);
rb_define_method(rb_cThread, "abort_on_exception", rb_thread_abort_exc, 0);
diff --git a/vm.c b/vm.c
index 3d7b76e..48796bc 100644
index 63141ba..553f180 100644
--- a/vm.c
+++ b/vm.c
@@ -1896,6 +1896,7 @@ ruby_thread_init(VALUE self)
Expand Down

0 comments on commit 4f8648e

Please sign in to comment.