Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 212718f

Browse files
committedJul 8, 2015
Merge remote-tracking branch 'origin' into 1.8.7
2 parents 98288bf + 5e2f095 commit 212718f

10 files changed

+75
-65
lines changed
 

‎vm/capi/handles.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace rubinius {
2626
diagnostics_.collections_++;
2727
state->memory()->collect_mature_now = true;
2828
}
29-
diagnostics_.objects_++;
3029
atomic::memory_barrier();
3130
return handle;
3231
}
@@ -44,7 +43,6 @@ namespace rubinius {
4443
diagnostics_.collections_++;
4544
state->memory()->collect_mature_now = true;
4645
}
47-
diagnostics_.objects_++;
4846
atomic::memory_barrier();
4947

5048
if(handle_index > UINT32_MAX) {
@@ -77,6 +75,8 @@ namespace rubinius {
7775
{
7876
std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);
7977

78+
diagnostics_.objects_ = 0;
79+
8080
for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
8181
Handle* chunk = allocator_->chunks_[i];
8282

@@ -92,6 +92,7 @@ namespace rubinius {
9292
// Strong references will already have been updated.
9393
if(!handle->weak_p()) {
9494
chunk_marks[i] = true;
95+
diagnostics_.objects_++;
9596
continue;
9697
}
9798

@@ -103,27 +104,29 @@ namespace rubinius {
103104
// a collection. In this state, valid objects are only in current.
104105
if(young->in_current_p(obj)) {
105106
chunk_marks[i] = true;
107+
diagnostics_.objects_++;
106108
// A weakref pointing to a forwarded young object
107109
} else if(obj->forwarded_p()) {
108110
handle->set_object(obj->forward());
109111
chunk_marks[i] = true;
112+
diagnostics_.objects_++;
110113
// A weakref pointing to a dead young object
111114
} else {
112115
handle->clear();
113-
diagnostics_.objects_--;
114116
}
115117
} else {
116118
// Not a young object, so won't be GC'd so mark
117119
// chunk as still active
118120
chunk_marks[i] = true;
121+
diagnostics_.objects_++;
119122
}
120123

121124
// A weakref pointing to a dead mature object
122125
} else if(!obj->marked_p(mark)) {
123126
handle->clear();
124-
diagnostics_.objects_--;
125127
} else {
126128
chunk_marks[i] = true;
129+
diagnostics_.objects_++;
127130
}
128131
}
129132
}
@@ -141,7 +144,7 @@ namespace rubinius {
141144

142145
allocator_->rebuild_freelist(&chunk_marks);
143146

144-
diagnostics_.bytes_ = allocator_->in_use_;
147+
diagnostics_.bytes_ = allocator_->in_use_ * sizeof(Handle);
145148
diagnostics_.modify();
146149
}
147150
}

‎vm/gc/baker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ namespace rubinius {
6060
diagnostics::Diagnostics::log();
6161

6262
utilities::logger::write("baker: diagnostics: " \
63+
"collections: %ld, " \
6364
"10%%: %ld, 20%%: %ld, 30%%: %ld, 40%%: %ld, 50%%: %ld, " \
6465
"60%%: %ld, 70%%: %ld, 80%%: %ld, 90%%: %ld",
66+
collections_,
6567
occupancy_histo_[0], occupancy_histo_[1], occupancy_histo_[2],
6668
occupancy_histo_[3], occupancy_histo_[4], occupancy_histo_[5],
6769
occupancy_histo_[6], occupancy_histo_[7], occupancy_histo_[8]);

‎vm/gc/baker.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,25 @@ namespace rubinius {
6262
public:
6363
const static int cPercentTiles = 10;
6464

65+
int64_t collections_;
6566
int64_t occupancy_histo_[cPercentTiles];
6667

6768
Diagnostics()
6869
: diagnostics::Diagnostics()
70+
, collections_(0)
6971
{
7072
for(int i = 0; i < cPercentTiles; i++) {
7173
occupancy_histo_[i] = 0;
7274
}
7375
}
7476

7577
void record_occupancy(double percentage) {
78+
modify();
79+
collections_++;
80+
7681
if(percentage < 0.0 || percentage > 100.0) return;
7782

7883
occupancy_histo_[int(percentage / cPercentTiles)]++;
79-
modify();
8084
}
8185

8286
void log();

‎vm/gc/code_manager.cpp

+11-25
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace rubinius {
1111
diagnostics::Diagnostics::log();
1212

1313
utilities::logger::write("code manager: diagnostics: " \
14-
"chunks: %ld, objects: %ld, bytes: %ld",
15-
chunks_, objects_, bytes_);
14+
"collections: %ld, chunks: %ld, objects: %ld, bytes: %ld",
15+
collections_, chunks_, objects_, bytes_);
1616
}
1717

1818
CodeManager::Chunk::Chunk(int size)
@@ -33,11 +33,6 @@ namespace rubinius {
3333
, last_chunk_(0)
3434
, current_chunk_(0)
3535
, current_index_(0)
36-
, freed_resources_(0)
37-
, total_allocated_(0)
38-
, total_freed_(0)
39-
, gc_triggered_(0)
40-
, bytes_used_(0)
4136
, diagnostics_(Diagnostics())
4237
{
4338
first_chunk_ = new Chunk(chunk_size_);
@@ -68,20 +63,11 @@ namespace rubinius {
6863
last_chunk_->next = c;
6964
last_chunk_ = c;
7065
current_chunk_ = c;
71-
diagnostics_.chunks_++;
7266
}
7367

7468
void CodeManager::add_resource(CodeResource* cr, bool* collect_now) {
7569
utilities::thread::Mutex::LockGuard guard(mutex_);
7670

77-
total_allocated_ += cr->size();
78-
bytes_used_ += cr->size();
79-
80-
if(total_allocated_ - gc_triggered_ > cGCTriggerThreshold) {
81-
gc_triggered_ = total_allocated_;
82-
*collect_now = true;
83-
}
84-
8571
for(;;) {
8672
while(current_index_ < chunk_size_) {
8773
if(current_chunk_->resources[current_index_] == 0) {
@@ -95,15 +81,19 @@ namespace rubinius {
9581
// Move on to the next one or add a new one
9682
current_index_ = 0;
9783
current_chunk_ = current_chunk_->next;
98-
if(!current_chunk_) add_chunk();
84+
if(!current_chunk_) {
85+
add_chunk();
86+
*collect_now = true;
87+
diagnostics_.collections_++;
88+
}
9989
}
10090
}
10191

10292
void CodeManager::sweep() {
10393
Chunk* chunk = first_chunk_;
10494
Chunk* prev = NULL;
10595

106-
freed_resources_ = 0;
96+
diagnostics_ = Diagnostics(diagnostics_.collections_);
10797

10898
State state(shared_->root_vm());
10999

@@ -112,10 +102,6 @@ namespace rubinius {
112102
for(int i = 0; i < chunk_size_; i++) {
113103
if(CodeResource* cr = chunk->resources[i]) {
114104
if(!cr->marked()) {
115-
total_freed_ += cr->size();
116-
bytes_used_ -= cr->size();
117-
118-
freed_resources_++;
119105
cr->cleanup(&state, this);
120106
delete cr;
121107
chunk->resources[i] = 0;
@@ -148,14 +134,14 @@ namespace rubinius {
148134
}
149135
delete chunk;
150136
chunk = prev->next;
151-
diagnostics_.chunks_--;
152137
} else {
153138
prev = chunk;
154139
chunk = chunk->next;
140+
diagnostics_.chunks_++;
155141
}
156-
157-
diagnostics_.modify();
158142
}
143+
144+
diagnostics_.modify();
159145
}
160146

161147
void CodeManager::clear_marks() {

‎vm/gc/code_manager.hpp

+9-29
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,25 @@ namespace rubinius {
3131
class Diagnostics : public diagnostics::MemoryDiagnostics {
3232
public:
3333
int64_t chunks_;
34+
int64_t collections_;
3435

3536
Diagnostics()
3637
: diagnostics::MemoryDiagnostics()
3738
, chunks_(0)
39+
, collections_(0)
40+
{ }
41+
42+
Diagnostics(int64_t collections)
43+
: diagnostics::MemoryDiagnostics()
44+
, chunks_(0)
45+
, collections_(collections)
3846
{ }
3947

4048
void log();
4149
};
4250

4351
private:
44-
const static int cDefaultChunkSize = 64;
45-
const static int cGCTriggerThreshold = 64 * 1024 * 1024;
52+
const static int cDefaultChunkSize = 1024 * 1024;
4653

4754
/**
4855
* A chunk of memory used to store an array of references to CodeResource
@@ -70,40 +77,13 @@ namespace rubinius {
7077
Chunk* current_chunk_;
7178
int current_index_;
7279

73-
int freed_resources_;
74-
int total_allocated_;
75-
int total_freed_;
76-
int gc_triggered_;
77-
78-
size_t bytes_used_;
79-
8080
Diagnostics diagnostics_;
8181

8282
public:
83-
int freed_resources() const {
84-
return freed_resources_;
85-
}
86-
87-
int total_allocated() const {
88-
return total_allocated_;
89-
}
90-
91-
int total_freed() const {
92-
return total_freed_;
93-
}
94-
9583
SharedState* shared() const {
9684
return shared_;
9785
}
9886

99-
size_t& size() {
100-
return bytes_used_;
101-
}
102-
103-
size_t size() const {
104-
return bytes_used_;
105-
}
106-
10787
Diagnostics& diagnostics() {
10888
return diagnostics_;
10989
}

‎vm/gc/immix.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ namespace rubinius {
2323
diagnostics::Diagnostics::log();
2424

2525
utilities::logger::write("immix: diagnostics: " \
26+
"collections: %ld, " \
2627
"objects: %ld, " \
2728
"bytes: %ld, " \
2829
"total_bytes: %ld, " \
2930
"chunks: %ld, " \
3031
"blocks: %ld, " \
3132
"holes: %ld, " \
3233
"percentage: %f",
33-
objects_, bytes_, total_bytes_, chunks_, blocks_, holes_, percentage_);
34+
collections_, objects_, bytes_, total_bytes_,
35+
chunks_, blocks_, holes_, percentage_);
3436
}
3537

3638
void ImmixGC::ObjectDescriber::added_chunk(int count) {
@@ -309,7 +311,7 @@ namespace rubinius {
309311
timer::StopWatch<timer::microseconds> timer(
310312
vm()->metrics().gc.immix_diagnostics_us);
311313

312-
diagnostics_ = Diagnostics();
314+
diagnostics_ = Diagnostics(diagnostics_.collections_);
313315

314316
// Now, calculate how much space we're still using.
315317
immix::Chunks& chunks = gc_.block_allocator().chunks();
@@ -328,6 +330,7 @@ namespace rubinius {
328330
diagnostics_.percentage_ =
329331
(double)diagnostics_.bytes_ / (double)diagnostics_.total_bytes_;
330332

333+
diagnostics_.collections_++;
331334
diagnostics_.modify();
332335
}
333336

‎vm/gc/immix.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace rubinius {
2222
public:
2323
class Diagnostics : public diagnostics::MemoryDiagnostics {
2424
public:
25+
int64_t collections_;
2526
int64_t total_bytes_;
2627
int64_t chunks_;
2728
int64_t blocks_;
@@ -30,6 +31,17 @@ namespace rubinius {
3031

3132
Diagnostics()
3233
: diagnostics::MemoryDiagnostics()
34+
, collections_(0)
35+
, total_bytes_(0)
36+
, chunks_(0)
37+
, blocks_(0)
38+
, holes_(0)
39+
, percentage_(0.0)
40+
{ }
41+
42+
Diagnostics(int64_t collections)
43+
: diagnostics::MemoryDiagnostics()
44+
, collections_(collections)
3345
, total_bytes_(0)
3446
, chunks_(0)
3547
, blocks_(0)

‎vm/gc/inflated_headers.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
namespace rubinius {
99
void InflatedHeaders::Diagnostics::log() {
10+
if(!modified_p()) return;
11+
12+
diagnostics::Diagnostics::log();
13+
14+
utilities::logger::write("inflated headers: diagnostics: " \
15+
"objects: %ld, bytes: %ld, collections: %ld\n",
16+
objects_, bytes_, collections_);
1017
}
1118

1219
InflatedHeader* InflatedHeaders::allocate(STATE, ObjectHeader* obj, uint32_t* index) {
@@ -18,6 +25,7 @@ namespace rubinius {
1825
*index = (uint32_t)header_index;
1926
InflatedHeader* header = allocator_->from_index(header_index);
2027
if(needs_gc) {
28+
diagnostics_.collections_++;
2129
state->memory()->collect_mature_now = true;
2230
}
2331
atomic::memory_barrier();
@@ -26,6 +34,9 @@ namespace rubinius {
2634

2735
void InflatedHeaders::deallocate_headers(unsigned int mark) {
2836
std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);
37+
38+
diagnostics_.objects_ = 0;
39+
2940
for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
3041
InflatedHeader* chunk = allocator_->chunks_[i];
3142

@@ -34,12 +45,16 @@ namespace rubinius {
3445

3546
if(header->marked_p(mark)) {
3647
chunk_marks[i] = true;
48+
diagnostics_.objects_++;
3749
} else {
3850
header->clear();
3951
}
4052
}
4153
}
4254

4355
allocator_->rebuild_freelist(&chunk_marks);
56+
57+
diagnostics_.bytes_ = allocator_->in_use_ * sizeof(InflatedHeader);
58+
diagnostics_.modify();
4459
}
4560
}

‎vm/gc/inflated_headers.hpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ namespace rubinius {
1111

1212
class InflatedHeaders {
1313
public:
14-
class Diagnostics : public diagnostics::Diagnostics {
14+
class Diagnostics : public diagnostics::MemoryDiagnostics {
1515
public:
16-
Diagnostics() { }
16+
int64_t collections_;
17+
18+
Diagnostics()
19+
: diagnostics::MemoryDiagnostics()
20+
, collections_(0)
21+
{ }
1722

1823
void log();
1924
};

‎vm/gc/mark_sweep.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace rubinius {
3535

3636
diagnostics::Diagnostics::log();
3737

38-
utilities::logger::write("mark_sweep: diagnostics: objects: %ld, bytes: %ld",
38+
utilities::logger::write("large objects: diagnostics: objects: %ld, bytes: %ld",
3939
objects_, bytes_);
4040
}
4141

0 commit comments

Comments
 (0)
Please sign in to comment.