Skip to content

Commit 1132e25

Browse files
committedJun 28, 2015
More Metrics cleanup.
1 parent 291c7c7 commit 1132e25

18 files changed

+52
-66
lines changed
 

‎vm/builtin/executable.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ namespace rubinius {
6262
return dis.send(state, call_frame, args);
6363
}
6464

65-
void Executable::add_inliner(ObjectMemory* om, CompiledCode* code) {
66-
if(!inliners_ || inliners_ == (Inliners*)cNil) inliners_ = new Inliners(om);
65+
void Executable::add_inliner(STATE, ObjectMemory* om, CompiledCode* code) {
66+
if(!inliners_ || inliners_ == (Inliners*)cNil) {
67+
inliners_ = new Inliners(state, om);
68+
}
6769
inliners_->inliners().push_back(code);
6870

6971
om->write_barrier(this, code);
@@ -106,8 +108,8 @@ namespace rubinius {
106108
}
107109
}
108110

109-
Inliners::Inliners(ObjectMemory* om) {
110-
om->add_code_resource(this);
111+
Inliners::Inliners(STATE, ObjectMemory* om) {
112+
om->add_code_resource(state, this);
111113
}
112114

113115
void Inliners::cleanup(STATE, CodeManager* cm) {

‎vm/builtin/executable.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace rubinius {
1818
std::vector<CompiledCode*> inliners_;
1919

2020
public:
21-
Inliners(ObjectMemory* om);
21+
Inliners(STATE, ObjectMemory* om);
2222

2323
std::vector<CompiledCode*>& inliners() {
2424
return inliners_;
@@ -81,7 +81,7 @@ namespace rubinius {
8181

8282
bool resolve_primitive(STATE);
8383

84-
void add_inliner(ObjectMemory* om, CompiledCode* code);
84+
void add_inliner(STATE, ObjectMemory* om, CompiledCode* code);
8585
void clear_inliners(STATE);
8686

8787
class Info : public TypeInfo {

‎vm/builtin/native_function.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ namespace rubinius {
264264
rubinius::bug("ffi_prep_cif failed");
265265
}
266266

267-
state->shared().om->add_code_resource(data);
267+
state->shared().om->add_code_resource(state, data);
268268
this->ffi_data = data;
269269
}
270270

‎vm/gc/mark_sweep.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ namespace rubinius {
2121

2222
MarkSweepGC::MarkSweepGC(ObjectMemory *om, Configuration& config)
2323
: GarbageCollector(om)
24-
, allocated_bytes(0)
25-
, allocated_objects(0)
2624
, collection_threshold(config.gc_marksweep_threshold)
2725
, next_collection_bytes(collection_threshold)
28-
, free_entries(true)
29-
, times_collected(0)
30-
, last_freed(0)
3126
{}
3227

3328
MarkSweepGC::~MarkSweepGC() { }
@@ -70,12 +65,6 @@ namespace rubinius {
7065
void MarkSweepGC::free_object(Object* obj, bool fast) {
7166
if(!fast) {
7267
delete_object(obj);
73-
74-
last_freed++;
75-
76-
object_memory_->state()->metrics().memory.large_objects--;
77-
object_memory_->state()->metrics().memory.large_bytes -=
78-
obj->size_in_bytes(object_memory_->state());
7968
}
8069

8170
obj->set_zone(UnspecifiedZone);
@@ -124,8 +113,6 @@ namespace rubinius {
124113

125114
timer::StopWatch<timer::microseconds> timer(metrics.gc.large_sweep_us);
126115

127-
last_freed = 0;
128-
129116
// Cleanup all weakrefs seen
130117
clean_weakrefs();
131118

‎vm/gc/mark_sweep.hpp

-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@ namespace rubinius {
2424
public:
2525
/* Data members */
2626
std::list<Object*> entries;
27-
size_t allocated_bytes;
28-
size_t allocated_objects;
2927
int collection_threshold;
3028
int next_collection_bytes;
31-
bool free_entries;
32-
int times_collected;
33-
int last_freed;
3429

3530
/* Prototypes */
3631

‎vm/llvm/inline.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ namespace rubinius {
268268
}
269269

270270
policy->increase_size(mcode);
271-
meth->add_inliner(ops_.llvm_state()->shared().om, ops_.root_method_info()->method());
271+
meth->add_inliner(ops_.llvm_state()->state(),
272+
ops_.llvm_state()->shared().om, ops_.root_method_info()->method());
272273

273274
inline_generic_method(klass, data, defined_in, code, mcode, hits);
274275
return true;
@@ -312,7 +313,8 @@ namespace rubinius {
312313
}
313314

314315
remember:
315-
meth->add_inliner(ops_.llvm_state()->shared().om, ops_.root_method_info()->method());
316+
meth->add_inliner(ops_.llvm_state()->state(),
317+
ops_.llvm_state()->shared().om, ops_.root_method_info()->method());
316318

317319
return true;
318320
}

‎vm/llvm/jit_compiler.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ namespace jit {
146146
mci_->address(), mci_->size());
147147

148148
// info.method()->set_jit_data(ctx.runtime_data_holder());
149-
ctx_->llvm_state()->shared().om->add_code_resource(ctx_->runtime_data_holder());
149+
ctx_->llvm_state()->shared().om->add_code_resource(
150+
ctx_->llvm_state()->state(), ctx_->runtime_data_holder());
150151
}
151152

152153
return mci_->address();

‎vm/llvm/state.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ namespace rubinius {
208208
}
209209

210210
void LLVMState::run(STATE) {
211+
state_ = state;
212+
211213
GCTokenImpl gct;
212214
JITCompileRequest* compile_request = nil<JITCompileRequest>();
213215
OnStack<1> os(state, compile_request);
@@ -392,7 +394,7 @@ namespace rubinius {
392394
}
393395

394396
Symbol* LLVMState::symbol(const std::string& sym) {
395-
return symbols_.lookup(&shared_, sym);
397+
return symbols_.lookup(state(), &shared_, sym);
396398
}
397399

398400
std::string LLVMState::symbol_debug_str(const Symbol* sym) {

‎vm/llvm/state.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ namespace rubinius {
8080
SymbolTable& symbols_;
8181

8282
SharedState& shared_;
83+
State* state_;
84+
8385
bool include_profiling_;
8486

8587
std::ostream* log_;
@@ -121,6 +123,10 @@ namespace rubinius {
121123
LLVMState(STATE);
122124
virtual ~LLVMState();
123125

126+
State* state() {
127+
return state_;
128+
}
129+
124130
void add_internal_functions();
125131
void enable(STATE);
126132

‎vm/machine_code.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace rubinius {
102102
specializations[i].jit_data = 0;
103103
}
104104

105-
state->shared().om->add_code_resource(this);
105+
state->shared().om->add_code_resource(state, this);
106106
}
107107

108108
MachineCode::~MachineCode() {

‎vm/metrics.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ namespace rubinius {
215215
slab_refills_fails += data.slab_refills_fails;
216216
data_objects += data.data_objects;
217217
capi_handles += data.capi_handles;
218-
capi_handles += data.capi_handles;
219218
inflated_headers += data.inflated_headers;
220219
}
221220
};

‎vm/object_memory.cpp

+3-17
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,6 @@ namespace rubinius {
443443
}
444444
}
445445

446-
// TODO: Fix API to support proper testing.
447-
void ObjectMemory::debug_marksweep(bool val) {
448-
if(val) {
449-
mark_sweep_->free_entries = false;
450-
} else {
451-
mark_sweep_->free_entries = true;
452-
}
453-
}
454-
455446
bool ObjectMemory::valid_object_p(Object* obj) {
456447
if(obj->young_object_p()) {
457448
return young_->validate_object(obj) == cValid;
@@ -569,8 +560,6 @@ namespace rubinius {
569560

570561
metrics::MetricsData& metrics = state->vm()->metrics();
571562
metrics.gc.young_count++;
572-
metrics.memory.capi_handles = capi_handles_->size();
573-
metrics.memory.inflated_headers = inflated_headers_->size();
574563

575564
data->global_cache()->prune_young();
576565

@@ -647,11 +636,6 @@ namespace rubinius {
647636
metrics::MetricsData& metrics = state->vm()->metrics();
648637
metrics.gc.immix_count++;
649638
metrics.gc.large_count++;
650-
metrics.memory.immix_bytes += immix_->bytes_allocated();
651-
metrics.memory.large_bytes += mark_sweep_->allocated_bytes;
652-
metrics.memory.symbols += shared_.symbols.size();
653-
metrics.memory.symbols_bytes += shared_.symbols.bytes_used();
654-
metrics.memory.code_bytes += code_manager_.size();
655639

656640
if(FinalizerThread* hdl = state->shared().finalizer_handler()) {
657641
hdl->finish_collection(state);
@@ -929,9 +913,11 @@ namespace rubinius {
929913
return mark_sweep_->validate_object(obj);
930914
}
931915

932-
void ObjectMemory::add_code_resource(CodeResource* cr) {
916+
void ObjectMemory::add_code_resource(STATE, CodeResource* cr) {
933917
utilities::thread::SpinLock::LockGuard guard(shared_.code_resource_lock());
934918

919+
state->vm()->metrics().memory.code_bytes += cr->size();
920+
935921
code_manager_.add_resource(cr, &collect_mature_now);
936922
}
937923

‎vm/object_memory.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,9 @@ namespace rubinius {
277277
bool inflate_for_contention(STATE, ObjectHeader* obj);
278278

279279
bool valid_object_p(Object* obj);
280-
void debug_marksweep(bool val);
281280
void add_type_info(TypeInfo* ti);
282281

283-
void add_code_resource(CodeResource* cr);
282+
void add_code_resource(STATE, CodeResource* cr);
284283
void memstats();
285284

286285
void validate_handles(capi::Handles* handles);

‎vm/oop.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ namespace rubinius {
3333
new_val.f.aux_word = ih_index;
3434
new_val.f.meaning = eAuxWordInflated;
3535

36+
state->vm()->metrics().memory.inflated_headers++;
37+
3638
// Make sure to include a barrier to the header is all properly initialized
3739
atomic::memory_barrier();
3840
return header.atomic_set(orig, new_val);

‎vm/symbol_table.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,35 @@ namespace rubinius {
8383
return k;
8484
}
8585

86-
size_t SymbolTable::add(std::string str, int enc) {
87-
bytes_used_ += (str.size() + sizeof(std::string) + sizeof(int) + sizeof(Kind));
86+
size_t SymbolTable::add(STATE, std::string str, int enc) {
87+
size_t bytes = (str.size() + sizeof(std::string) + sizeof(int) + sizeof(Kind));
88+
bytes_used_ += bytes;
8889

8990
strings.push_back(str);
9091
encodings.push_back(enc);
9192
kinds.push_back(eUnknown);
93+
94+
state->vm()->metrics().memory.symbols++;
95+
state->vm()->metrics().memory.symbols_bytes += bytes;
96+
9297
return strings.size() - 1;
9398
}
9499

95100
Symbol* SymbolTable::lookup(STATE, const char* str, size_t length) {
96-
return lookup(str, length, Encoding::eAscii, state->hash_seed());
101+
return lookup(state, str, length, Encoding::eAscii, state->hash_seed());
97102
}
98103

99-
Symbol* SymbolTable::lookup(SharedState* shared, const std::string& str) {
100-
return lookup(str.data(), str.size(), Encoding::eAscii, shared->hash_seed);
104+
Symbol* SymbolTable::lookup(STATE, SharedState* shared, const std::string& str) {
105+
return lookup(state, str.data(), str.size(), Encoding::eAscii, shared->hash_seed);
101106
}
102107

103108
Symbol* SymbolTable::lookup(STATE, const std::string& str) {
104-
return lookup(str.data(), str.size(), Encoding::eAscii, state->hash_seed());
109+
return lookup(state, str.data(), str.size(), Encoding::eAscii, state->hash_seed());
105110
}
106111

107-
Symbol* SymbolTable::lookup(const char* str, size_t length, int enc, uint32_t seed) {
112+
Symbol* SymbolTable::lookup(STATE, const char* str, size_t length,
113+
int enc, uint32_t seed)
114+
{
108115
size_t sym;
109116

110117
hashval hash = String::hash_str((unsigned char*)str, length, seed);
@@ -115,7 +122,7 @@ namespace rubinius {
115122
utilities::thread::SpinLock::LockGuard guard(lock_);
116123
SymbolMap::iterator entry = symbols.find(hash);
117124
if(entry == symbols.end()) {
118-
sym = add(std::string(str, length), enc);
125+
sym = add(state, std::string(str, length), enc);
119126
SymbolIds v(1, sym);
120127
symbols[hash] = v;
121128
} else {
@@ -126,7 +133,7 @@ namespace rubinius {
126133

127134
if(!strncmp(s.data(), str, length) && e == enc) return Symbol::from_index(*i);
128135
}
129-
sym = add(std::string(str, length), enc);
136+
sym = add(state, std::string(str, length), enc);
130137
v.push_back(sym);
131138
}
132139
}
@@ -150,7 +157,7 @@ namespace rubinius {
150157
if(CBOOL(str->ascii_only_p(state))) {
151158
enc = Encoding::eAscii;
152159
}
153-
return lookup(bytes, size, enc, state->hash_seed());
160+
return lookup(state, bytes, size, enc, state->hash_seed());
154161
}
155162

156163
String* SymbolTable::lookup_string(STATE, const Symbol* sym) {

‎vm/symbol_table.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ namespace rubinius {
7979
return symbols.size();
8080
};
8181

82-
Symbol* lookup(SharedState* shared, const std::string& str);
82+
Symbol* lookup(STATE, SharedState* shared, const std::string& str);
8383
Symbol* lookup(STATE, const std::string& str);
8484
Symbol* lookup(STATE, const char* str, size_t length);
85-
Symbol* lookup(const char* str, size_t length, int enc, uint32_t seed);
85+
Symbol* lookup(STATE, const char* str, size_t length, int enc, uint32_t seed);
8686
Symbol* lookup(STATE, String* str);
8787
String* lookup_string(STATE, const Symbol* sym);
8888

@@ -94,7 +94,7 @@ namespace rubinius {
9494

9595
Kind kind(STATE, const Symbol* sym);
9696

97-
size_t add(std::string str, int enc);
97+
size_t add(STATE, std::string str, int enc);
9898
Kind detect_kind(STATE, const Symbol* sym);
9999
};
100100
};

‎vm/test/test_object_memory.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ class TestObjectMemory : public CxxTest::TestSuite, public VMTest {
304304
ObjectMemory& om = *state->memory();
305305
Object* mature;
306306

307-
om.debug_marksweep(true);
308-
309307
om.large_object_threshold = 10;
310308

311309
mature = util_new_object(om,20);

‎vm/test/test_symbol_table.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestSymbolTable : public CxxTest::TestSuite, public VMTest {
3030
}
3131

3232
void test_detect_kind_with_unicode_constant() {
33-
Symbol* sym = symbols->lookup("Pettsonλ", 9, Encoding::eUtf8, 0);
33+
Symbol* sym = symbols->lookup(state, "Pettsonλ", 9, Encoding::eUtf8, 0);
3434
SymbolTable::Kind kind = symbols->detect_kind(state, sym);
3535

3636
TS_ASSERT_EQUALS(kind, SymbolTable::eConstant);

0 commit comments

Comments
 (0)
Please sign in to comment.