Skip to content

Commit f95ebcf

Browse files
committed
Added a few more machine metrics.
1 parent e7dcab3 commit f95ebcf

12 files changed

+42
-9
lines changed

machine/builtin/code_db.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
#include "on_stack.hpp"
66
#include "ontology.hpp"
77
#include "marshal.hpp"
8+
#include "metrics.hpp"
89
#include "thread_phase.hpp"
910

1011
#include "builtin/class.hpp"
1112
#include "builtin/code_db.hpp"
1213
#include "builtin/compiled_code.hpp"
1314
#include "builtin/string.hpp"
1415

16+
#include "instruments/timing.hpp"
17+
1518
#include "util/thread.hpp"
1619

1720
#include <fcntl.h>
@@ -148,6 +151,9 @@ namespace rubinius {
148151
CompiledCode* CodeDB::load(STATE, const char* m_id) {
149152
MutexLockUnmanaged guard(state, state->shared().codedb_lock());
150153

154+
timer::StopWatch<timer::microseconds> timer(
155+
state->vm()->metrics().codedb.load_us);
156+
151157
CodeDBMap::const_iterator index = codedb_index.find(std::string(m_id));
152158

153159
if(index == codedb_index.end()) {

machine/builtin/compiled_code.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ namespace rubinius {
113113
}
114114

115115
MachineCode* CompiledCode::internalize(STATE) {
116+
timer::StopWatch<timer::microseconds> timer(
117+
state->vm()->metrics().machine.bytecode_internalizer_us);
118+
116119
MachineCode* mcode = machine_code();
117120

118121
atomic::memory_barrier();

machine/builtin/system.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace rubinius {
142142
return Primitives::failure();
143143
}
144144

145-
CompiledFile* cf = CompiledFile::load(stream);
145+
CompiledFile* cf = CompiledFile::load(state, stream);
146146
if(cf->magic != "!RBIX") {
147147
delete cf;
148148
return Primitives::failure();

machine/bytecode_verifier.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ namespace rubinius {
9898
}
9999

100100
void BytecodeVerifier::verify(STATE) {
101+
timer::StopWatch<timer::microseconds> timer(
102+
state->vm()->metrics().machine.bytecode_verifier_us);
103+
101104
// Do this setup here instead of the constructor so we can do
102105
// some validation of the CompiledCode's fields we read them.
103106

machine/compiled_file.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
#include "memory.hpp"
1818
#include "object_utils.hpp"
1919

20+
#include "instruments/timing.hpp"
21+
22+
2023
namespace rubinius {
21-
CompiledFile* CompiledFile::load(std::istream& stream) {
24+
CompiledFile* CompiledFile::load(STATE, std::istream& stream) {
25+
timer::StopWatch<timer::microseconds> timer(
26+
state->vm()->metrics().machine.bytecode_load_us);
27+
2228
std::string magic;
2329
uint64_t signature;
2430
int version;

machine/compiled_file.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace rubinius {
2929
, stream(stream)
3030
{}
3131

32-
static CompiledFile* load(std::istream& stream);
32+
static CompiledFile* load(STATE, std::istream& stream);
3333
Object* body(STATE);
3434
bool execute(STATE);
3535
};

machine/drivers/compile.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main(int argc, char** argv) {
6363

6464
ifstream stream(input.c_str());
6565

66-
CompiledFile* cf = CompiledFile::load(stream);
66+
CompiledFile* cf = CompiledFile::load(env.state, stream);
6767
if(cf->magic != "!RBIX") throw std::runtime_error("Invalid file");
6868

6969
CompiledCode* meth = as<CompiledCode>(cf->body(env.state));

machine/drivers/jit-test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int argc, char **argv) {
3535
return 1;
3636
}
3737

38-
CompiledFile* cf = CompiledFile::load(stream);
38+
CompiledFile* cf = CompiledFile::load(state, stream);
3939
if(cf->magic != "!RBIX") {
4040
cout << "Invalid file.\n";
4141
}

machine/environment.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ namespace rubinius {
528528
throw std::runtime_error(msg);
529529
}
530530

531-
CompiledFile* cf = CompiledFile::load(stream);
531+
CompiledFile* cf = CompiledFile::load(state, stream);
532532
if(cf->magic != "!RBIX") {
533533
std::ostringstream msg;
534534
msg << "attempted to open a bytecode file with invalid magic identifier"

machine/metrics.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ namespace rubinius {
362362
"machine.methods.invoked", metrics_data_.machine.methods_invoked));
363363
metrics_map_.push_back(new MetricsItem(
364364
"machine.blocks.invoked", metrics_data_.machine.blocks_invoked));
365+
metrics_map_.push_back(new MetricsItem(
366+
"machine.bytecode.load.us", metrics_data_.machine.bytecode_load_us));
367+
metrics_map_.push_back(new MetricsItem(
368+
"machine.bytecode.verifier.us", metrics_data_.machine.bytecode_verifier_us));
369+
metrics_map_.push_back(new MetricsItem(
370+
"machine.bytecode.internalizer.us", metrics_data_.machine.bytecode_internalizer_us));
365371

366372
// Memory metrics
367373
metrics_map_.push_back(new MetricsItem(

machine/metrics.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ namespace rubinius {
167167
metric backtrace_us;
168168
metric methods_invoked;
169169
metric blocks_invoked;
170+
metric bytecode_load_us;
171+
metric bytecode_verifier_us;
172+
metric bytecode_internalizer_us;
170173

171174
MachineMetrics() {
172175
checkpoints = 0;
@@ -176,6 +179,9 @@ namespace rubinius {
176179
backtrace_us = 0;
177180
methods_invoked = 0;
178181
blocks_invoked = 0;
182+
bytecode_load_us = 0;
183+
bytecode_verifier_us = 0;
184+
bytecode_internalizer_us = 0;
179185
}
180186

181187
void add(MachineMetrics& data) {
@@ -186,6 +192,9 @@ namespace rubinius {
186192
backtrace_us += data.backtrace_us;
187193
methods_invoked += data.methods_invoked;
188194
blocks_invoked += data.blocks_invoked;
195+
bytecode_load_us += data.bytecode_load_us;
196+
bytecode_verifier_us += data.bytecode_verifier_us;
197+
bytecode_internalizer_us += data.bytecode_internalizer_us;
189198
}
190199
};
191200

machine/test/test_compiled_file.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestCompiledFile : public CxxTest::TestSuite, public VMTest {
3030
std::istringstream stream;
3131
stream.str("!RBIX\n1\n42\nt");
3232

33-
CompiledFile* cf = CompiledFile::load(stream);
33+
CompiledFile* cf = CompiledFile::load(state, stream);
3434
TS_ASSERT_EQUALS(cf->magic, std::string("!RBIX"));
3535
TS_ASSERT_EQUALS(cf->signature, 1ULL);
3636
TS_ASSERT_EQUALS(cf->version, 42);
@@ -41,15 +41,15 @@ class TestCompiledFile : public CxxTest::TestSuite, public VMTest {
4141
std::istringstream stream;
4242
stream.str("!RBIX\n1\n42\nt");
4343

44-
CompiledFile* cf = CompiledFile::load(stream);
44+
CompiledFile* cf = CompiledFile::load(state, stream);
4545
TS_ASSERT_EQUALS(cf->body(state), cTrue);
4646
}
4747

4848
void test_load_file() {
4949
std::fstream stream("machine/test/fixture.rbc_");
5050
TS_ASSERT(!!stream);
5151

52-
CompiledFile* cf = CompiledFile::load(stream);
52+
CompiledFile* cf = CompiledFile::load(state, stream);
5353
TS_ASSERT_EQUALS(cf->magic, "!RBIX");
5454

5555
CompiledCode* code = try_as<CompiledCode>(cf->body(state));

0 commit comments

Comments
 (0)