Skip to content

Commit a8dcb34

Browse files
committedJun 25, 2015
Removed young generation auto-tuning.
1 parent d63ccf5 commit a8dcb34

15 files changed

+72
-475
lines changed
 

‎library/rubinius/configuration.rb

+5-23
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,15 @@
44
Rubinius::ConfigurationVariables.define do |c|
55

66
c.section "gc" do |s|
7-
s.vm_variable "young_initial_bytes", 3145728,
8-
"The initial number of bytes the young generation of the GC should use"
9-
10-
s.vm_variable "young_max_bytes", 5 * 3145728,
11-
"The maximum number of bytes the young generation of the GC should use"
12-
13-
s.vm_variable "young_autotune_size", true,
14-
"Set whether or not the young GC should autotune the size"
15-
16-
s.vm_variable "young_autotune_factor", 8,
17-
"Set the young GC size autotune factor. This is the denominator of the fraction of total memory used for young GC"
7+
s.vm_variable "young_bytes", (40 * 1024 * 1024),
8+
"The number of bytes the young generation of the GC should use"
189

1910
s.vm_variable "young_lifetime", 2,
2011
"How many young GC cycles an object lives before promotion"
2112

22-
s.vm_variable "young_autotune_lifetime", true,
23-
"Set whether or not the young GC should adjust promotion age for performance"
24-
25-
s.vm_variable "large_object", (50 * 1024),
13+
s.vm_variable "large_object", (1024 * 1024),
2614
"The size (in bytes) of the large object threshold"
2715

28-
s.vm_variable "show", :bool,
29-
"Display information whenever the GC runs"
30-
31-
s.vm_variable "noisy", :bool,
32-
"Beep whenever the GC runs (once for young, twice for mature). Requires gc.show"
33-
3416
s.vm_variable "immix.concurrent", true,
3517
"Set whether we want the Immix mark phase to run concurrently"
3618

@@ -43,10 +25,10 @@
4325
s.vm_variable "autopack", true,
4426
"Set whether or not objects should be packed tightly in memory"
4527

46-
s.vm_variable "marksweep_threshold", (10 * 1024 * 1024),
28+
s.vm_variable "marksweep_threshold", (25 * 1024 * 1024),
4729
"The number of bytes allocated before the marksweep GC region is collected"
4830

49-
s.vm_variable "malloc_threshold", 104857600,
31+
s.vm_variable "malloc_threshold", (25 * 1024 * 1024),
5032
"How many bytes allocated by C extensions til the GC is run"
5133
end
5234

‎vm/gc/baker.cpp

+13-110
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "builtin/io.hpp"
1111

1212
#include "call_frame.hpp"
13+
#include "configuration.hpp"
1314

1415
#include "gc/gc.hpp"
1516

@@ -31,27 +32,16 @@ namespace rubinius {
3132
* - Heap A and Heap B, which get one quarter of the heap each. Heaps A and B
3233
* alternate between being the Current and Next space on each collection.
3334
*/
34-
BakerGC::BakerGC(ObjectMemory *om, size_t bytes)
35+
BakerGC::BakerGC(ObjectMemory *om, Configuration& config)
3536
: GarbageCollector(om)
36-
, full(new Heap(bytes))
37-
, eden(new Heap(full->allocate(bytes / 2), bytes / 2))
38-
, heap_a(new Heap(full->allocate(bytes / 4), bytes / 4))
39-
, heap_b(new Heap(full->allocate(bytes / 4), bytes / 4))
40-
, full_new(NULL)
41-
, eden_new(NULL)
42-
, heap_a_new(NULL)
43-
, heap_b_new(NULL)
37+
, bytes_(config.gc_young_bytes * 2)
38+
, full(new Heap(bytes_))
39+
, eden(new Heap(full->allocate(bytes_ / 2), bytes_ / 2))
40+
, heap_a(new Heap(full->allocate(bytes_ / 4), bytes_ / 4))
41+
, heap_b(new Heap(full->allocate(bytes_ / 4), bytes_ / 4))
4442
, current(heap_a)
4543
, next(heap_b)
46-
, total_objects(0)
47-
, current_byte_size_(bytes)
48-
, requested_byte_size_(bytes)
49-
, original_lifetime_(1)
50-
, lifetime_(1)
51-
, copy_spills_(0)
52-
, promoted_objects_(0)
53-
, tune_threshold_(0)
54-
, autotune_lifetime_(false)
44+
, lifetime_(config.gc_young_lifetime)
5545
{
5646
reset();
5747
}
@@ -98,9 +88,7 @@ namespace rubinius {
9888
} else if(likely(next->enough_space_p(
9989
obj->size_in_bytes(object_memory_->state())))) {
10090
copy = next->move_object(object_memory_->state(), obj);
101-
total_objects++;
10291
} else {
103-
copy_spills_++;
10492
copy = object_memory_->promote_object(obj);
10593
promoted_push(copy);
10694
}
@@ -137,18 +125,10 @@ namespace rubinius {
137125
return next->fully_scanned_p();
138126
}
139127

140-
const static double cOverFullThreshold = 95.0;
141-
const static int cOverFullTimes = 3;
142-
const static size_t cMinimumLifetime = 1;
143-
144-
const static double cUnderFullThreshold = 20.0;
145-
const static int cUnderFullTimes = -3;
146-
const static size_t cMaximumLifetime = 6;
147-
148128
/**
149129
* Perform garbage collection on the young objects.
150130
*/
151-
void BakerGC::collect(GCData* data, YoungCollectStats* stats) {
131+
void BakerGC::collect(GCData* data) {
152132

153133
#ifdef HAVE_VALGRIND_H
154134
(void)VALGRIND_MAKE_MEM_DEFINED(next->start().as_int(), next->size());
@@ -157,15 +137,8 @@ namespace rubinius {
157137
mprotect(next->start(), next->size(), PROT_READ | PROT_WRITE);
158138
mprotect(current->start(), current->size(), PROT_READ | PROT_WRITE);
159139

160-
check_growth_start();
161-
162140
ObjectArray *current_rs = object_memory_->swap_remember_set();
163141

164-
total_objects = 0;
165-
166-
copy_spills_ = 0;
167-
reset_promoted();
168-
169142
// Start by copying objects in the remember set
170143
for(ObjectArray::iterator oi = current_rs->begin();
171144
oi != current_rs->end();
@@ -199,7 +172,10 @@ namespace rubinius {
199172
}
200173
}
201174

202-
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator()); i.more(); i.advance()) {
175+
for(Allocator<capi::Handle>::Iterator i(data->handles()->allocator());
176+
i.more();
177+
i.advance())
178+
{
203179
if(!i->in_use_p()) continue;
204180

205181
if(!i->weak_p() && i->object()->young_object_p()) {
@@ -293,47 +269,9 @@ namespace rubinius {
293269
Heap* x = next;
294270
next = current;
295271
current = x;
296-
297-
if(stats) {
298-
stats->lifetime = lifetime_;
299-
stats->percentage_used = current->percentage_used();
300-
stats->promoted_objects = promoted_objects_;
301-
stats->excess_objects = copy_spills_;
302-
}
303-
304-
// Tune the age at which promotion occurs
305-
if(autotune_lifetime_) {
306-
double used = current->percentage_used();
307-
if(used > cOverFullThreshold) {
308-
if(tune_threshold_ >= cOverFullTimes) {
309-
if(lifetime_ > cMinimumLifetime) lifetime_--;
310-
} else {
311-
tune_threshold_++;
312-
}
313-
} else if(used < cUnderFullThreshold) {
314-
if(tune_threshold_ <= cUnderFullTimes) {
315-
if(lifetime_ < cMaximumLifetime) lifetime_++;
316-
} else {
317-
tune_threshold_--;
318-
}
319-
} else if(tune_threshold_ > 0) {
320-
tune_threshold_--;
321-
} else if(tune_threshold_ < 0) {
322-
tune_threshold_++;
323-
} else if(tune_threshold_ == 0) {
324-
if(lifetime_ < original_lifetime_) {
325-
lifetime_++;
326-
} else if(lifetime_ > original_lifetime_) {
327-
lifetime_--;
328-
}
329-
}
330-
}
331-
332272
}
333273

334274
void BakerGC::reset() {
335-
check_growth_finish();
336-
337275
next->reset();
338276
eden->reset();
339277

@@ -362,41 +300,6 @@ namespace rubinius {
362300
return true;
363301
}
364302

365-
void BakerGC::check_growth_start() {
366-
if(unlikely(current_byte_size_ != requested_byte_size_)) {
367-
368-
full_new = new Heap(requested_byte_size_);
369-
eden_new = new Heap(full_new->allocate(requested_byte_size_ / 2), requested_byte_size_ / 2);
370-
heap_a_new = new Heap(full_new->allocate(requested_byte_size_ / 4), requested_byte_size_ / 4);
371-
heap_b_new = new Heap(full_new->allocate(requested_byte_size_ / 4), requested_byte_size_ / 4);
372-
373-
// Install the next pointer so we move objects to the new memory space.
374-
next = heap_a_new;
375-
}
376-
}
377-
378-
void BakerGC::check_growth_finish() {
379-
if(unlikely(full_new)) {
380-
delete heap_a;
381-
delete heap_b;
382-
delete eden;
383-
delete full;
384-
heap_a = heap_a_new;
385-
heap_b = heap_b_new;
386-
eden = eden_new;
387-
full = full_new;
388-
current = heap_a_new;
389-
next = heap_b_new;
390-
391-
heap_a_new = NULL;
392-
heap_b_new = NULL;
393-
eden_new = NULL;
394-
full_new = NULL;
395-
396-
current_byte_size_ = requested_byte_size_;
397-
}
398-
}
399-
400303
void BakerGC::scan_mark_set() {
401304
// Scan any mature objects in the mark set
402305
// since they might refer to young objects.

0 commit comments

Comments
 (0)