Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reworked ObjectMemory diagnostics.
  • Loading branch information
brixen committed Jul 8, 2015
1 parent 2dcdbb9 commit 12b9902
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 57 deletions.
2 changes: 1 addition & 1 deletion vm/gc/baker.cpp
Expand Up @@ -60,7 +60,7 @@ namespace rubinius {
diagnostics::Diagnostics::log();

utilities::logger::write("baker: diagnostics: " \
"collections: %ld, bytes: %ld" \
"collections: %ld, bytes: %ld, " \
"10%%: %ld, 20%%: %ld, 30%%: %ld, 40%%: %ld, 50%%: %ld, " \
"60%%: %ld, 70%%: %ld, 80%%: %ld, 90%%: %ld",
collections_, bytes_,
Expand Down
4 changes: 2 additions & 2 deletions vm/gc/immix.hpp
@@ -1,5 +1,5 @@
#ifndef RBX_GC_IMMIX
#define RBX_GC_IMMIX
#ifndef RBX_GC_IMMIX_HPP
#define RBX_GC_IMMIX_HPP

#include "util/address.hpp"
#include "util/immix.hpp"
Expand Down
5 changes: 5 additions & 0 deletions vm/gc/inflated_headers.hpp
@@ -1,3 +1,6 @@
#ifndef RBX_GC_INFLATED_HEADERS_HPP
#define RBX_GC_INFLATED_HEADERS_HPP

#include <stddef.h>
#include <list>
#include "diagnostics.hpp"
Expand Down Expand Up @@ -55,3 +58,5 @@ namespace rubinius {
}
};
}

#endif
31 changes: 8 additions & 23 deletions vm/object_memory.cpp
Expand Up @@ -6,13 +6,17 @@
#include "config.h"
#include "vm.hpp"
#include "object_memory.hpp"

#include "capi/tag.hpp"

#include "gc/mark_sweep.hpp"
#include "gc/baker.hpp"
#include "gc/immix.hpp"
#include "gc/inflated_headers.hpp"
#include "gc/walker.hpp"

#include "system_diagnostics.hpp"

#if ENABLE_LLVM
#include "llvm/state.hpp"
#endif
Expand Down Expand Up @@ -54,27 +58,6 @@ namespace rubinius {

Object* object_watch = 0;

void ObjectMemory::Diagnostics::log() {
diagnostics::Diagnostics::log();

baker_->diagnostics().log();
immix_->diagnostics().log();
mark_sweep_->diagnostics().log();
headers_->diagnostics().log();
handles_->diagnostics().log();
code_->diagnostics().log();
symbols_->diagnostics().log();

utilities::logger::write("object memory: diagnostics: total memory: %ld",
baker_->diagnostics().bytes_ +
immix_->diagnostics().bytes_ +
mark_sweep_->diagnostics().bytes_ +
headers_->diagnostics().bytes_ +
handles_->diagnostics().bytes_ +
code_->diagnostics().bytes_ +
symbols_->diagnostics().bytes_);
}

/* ObjectMemory methods */
ObjectMemory::ObjectMemory(VM* vm, SharedState& shared)
: young_(new BakerGC(this, shared.config))
Expand All @@ -90,8 +73,10 @@ namespace rubinius {
, mature_gc_in_progress_(false)
, slab_size_(4096)
, shared_(vm->shared)
, diagnostics_(Diagnostics(young_, immix_, mark_sweep_,
inflated_headers_, capi_handles_, &code_manager_, &shared.symbols))
, diagnostics_(new diagnostics::ObjectDiagnostics(young_->diagnostics(),
immix_->diagnostics(), mark_sweep_->diagnostics(),
inflated_headers_->diagnostics(), capi_handles_->diagnostics(),
code_manager_.diagnostics(), shared.symbols.diagnostics()))
, collect_young_now(false)
, collect_mature_now(false)
, vm_(vm)
Expand Down
34 changes: 6 additions & 28 deletions vm/object_memory.hpp
Expand Up @@ -35,6 +35,10 @@ namespace rubinius {
class FinalizerThread;
class ImmixMarker;

namespace diagnostics {
class ObjectDiagnostics;
}

namespace gc {
class Slab;
}
Expand Down Expand Up @@ -68,32 +72,6 @@ namespace rubinius {
*/

class ObjectMemory : public gc::WriteBarrier {
public:
class Diagnostics : public diagnostics::Diagnostics {
BakerGC* baker_;
ImmixGC* immix_;
MarkSweepGC* mark_sweep_;
InflatedHeaders* headers_;
capi::Handles* handles_;
CodeManager* code_;
SymbolTable* symbols_;

public:
Diagnostics(BakerGC* baker, ImmixGC* immix, MarkSweepGC* mark_sweep,
InflatedHeaders* inflated_headers, capi::Handles* capi_handles,
CodeManager* code_manager, SymbolTable* symbols)
: baker_(baker)
, immix_(immix)
, mark_sweep_(mark_sweep)
, headers_(inflated_headers)
, handles_(capi_handles)
, code_(code_manager)
, symbols_(symbols)
{ }

void log();
};

private:
utilities::thread::SpinLock allocation_lock_;
utilities::thread::SpinLock inflation_lock_;
Expand Down Expand Up @@ -145,7 +123,7 @@ namespace rubinius {

SharedState& shared_;

Diagnostics diagnostics_;
diagnostics::ObjectDiagnostics* diagnostics_;

public:
/// Flag indicating whether a young collection should be performed soon
Expand Down Expand Up @@ -342,7 +320,7 @@ namespace rubinius {
mature_gc_in_progress_ = false;
}

Diagnostics& diagnostics() {
diagnostics::ObjectDiagnostics* diagnostics() {
return diagnostics_;
}

Expand Down
27 changes: 26 additions & 1 deletion vm/system_diagnostics.cpp
Expand Up @@ -2,8 +2,33 @@

namespace rubinius {
namespace diagnostics {
void ObjectDiagnostics::log() {
bool summarize = baker_.modified_p() || immix_.modified_p() ||
mark_sweep_.modified_p() || headers_.modified_p() ||
handles_.modified_p() || code_.modified_p() || symbols_.modified_p();

baker_.log();
immix_.log();
mark_sweep_.log();
headers_.log();
handles_.log();
code_.log();
symbols_.log();

if(summarize) {
utilities::logger::write("object memory: diagnostics: total memory: %ld",
baker_.bytes_ +
immix_.bytes_ +
mark_sweep_.bytes_ +
headers_.bytes_ +
handles_.bytes_ +
code_.bytes_ +
symbols_.bytes_);
}
}

void SystemDiagnostics::log() {
memory_.log();
memory_->log();
}
}
}
42 changes: 40 additions & 2 deletions vm/system_diagnostics.hpp
Expand Up @@ -3,14 +3,52 @@

#include "diagnostics.hpp"
#include "object_memory.hpp"
#include "symbol_table.hpp"

#include "capi/handles.hpp"

#include "gc/baker.hpp"
#include "gc/code_manager.hpp"
#include "gc/immix.hpp"
#include "gc/inflated_headers.hpp"
#include "gc/mark_sweep.hpp"

namespace rubinius {
namespace diagnostics {
class ObjectDiagnostics {
rubinius::BakerGC::Diagnostics& baker_;
rubinius::ImmixGC::Diagnostics& immix_;
rubinius::MarkSweepGC::Diagnostics& mark_sweep_;
rubinius::InflatedHeaders::Diagnostics& headers_;
rubinius::capi::Handles::Diagnostics& handles_;
rubinius::CodeManager::Diagnostics& code_;
rubinius::SymbolTable::Diagnostics& symbols_;

public:
ObjectDiagnostics(rubinius::BakerGC::Diagnostics& baker,
rubinius::ImmixGC::Diagnostics& immix,
rubinius::MarkSweepGC::Diagnostics& mark_sweep,
rubinius::InflatedHeaders::Diagnostics& inflated_headers,
rubinius::capi::Handles::Diagnostics& capi_handles,
rubinius::CodeManager::Diagnostics& code_manager,
rubinius::SymbolTable::Diagnostics& symbols)
: baker_(baker)
, immix_(immix)
, mark_sweep_(mark_sweep)
, headers_(inflated_headers)
, handles_(capi_handles)
, code_(code_manager)
, symbols_(symbols)
{ }

void log();
};

class SystemDiagnostics {
rubinius::ObjectMemory::Diagnostics& memory_;
ObjectDiagnostics* memory_;

public:
SystemDiagnostics(rubinius::ObjectMemory::Diagnostics& memory)
SystemDiagnostics(ObjectDiagnostics* memory)
: memory_(memory)
{ }

Expand Down

0 comments on commit 12b9902

Please sign in to comment.