short profiler logs
This commit is contained in:
parent
3f42a8f16d
commit
50e10586f1
5 changed files with 21 additions and 88 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
#include "chunk.hpp"
|
#include "chunk.hpp"
|
||||||
#include "profiler.hpp"
|
#include "profiler.hpp"
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
#define HEAP_SIZE 320//65536
|
#define HEAP_SIZE 320//65536
|
||||||
|
|
@ -17,6 +18,10 @@
|
||||||
#define HEAP_SIZE 16000//65536
|
#define HEAP_SIZE 16000//65536
|
||||||
#define FREE_THRESH (uint) 100
|
#define FREE_THRESH (uint) 100
|
||||||
>>>>>>> c09da8a (now it works ok???)
|
>>>>>>> c09da8a (now it works ok???)
|
||||||
|
=======
|
||||||
|
#define HEAP_SIZE 160000//65536
|
||||||
|
#define FREE_THRESH (uint) 5
|
||||||
|
>>>>>>> 5056624 (short profiler logs)
|
||||||
// #define HEAP_DEBUG
|
// #define HEAP_DEBUG
|
||||||
=======
|
=======
|
||||||
#define HEAP_SIZE 2097152 //256 //65536 //2097152
|
#define HEAP_SIZE 2097152 //256 //65536 //2097152
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace GC {
|
||||||
|
|
||||||
enum RecordOption
|
enum RecordOption
|
||||||
{
|
{
|
||||||
|
TimingInfo = 0,
|
||||||
FunctionCalls = (GC::AllocStart | GC::CollectStart | GC::MarkStart | GC::SweepStart | GC::FreeStart),
|
FunctionCalls = (GC::AllocStart | GC::CollectStart | GC::MarkStart | GC::SweepStart | GC::FreeStart),
|
||||||
ChunkOps = (GC::ChunkMarked | GC::ChunkSwept | GC::ChunkFreed | GC::NewChunk | GC::ReusedChunk),
|
ChunkOps = (GC::ChunkMarked | GC::ChunkSwept | GC::ChunkFreed | GC::NewChunk | GC::ReusedChunk),
|
||||||
AllOps = 0xFFFFFF
|
AllOps = 0xFFFFFF
|
||||||
|
|
@ -41,7 +42,7 @@ namespace GC {
|
||||||
std::vector<GCEvent *> m_events;
|
std::vector<GCEvent *> m_events;
|
||||||
ProfilerEvent *m_last_prof_event {new ProfilerEvent(HeapInit)};
|
ProfilerEvent *m_last_prof_event {new ProfilerEvent(HeapInit)};
|
||||||
std::vector<ProfilerEvent *> m_prof_events;
|
std::vector<ProfilerEvent *> m_prof_events;
|
||||||
RecordOption flags;
|
RecordOption flags {AllOps};
|
||||||
|
|
||||||
std::chrono::microseconds alloc_time {0};
|
std::chrono::microseconds alloc_time {0};
|
||||||
// size_t alloc_counts {0};
|
// size_t alloc_counts {0};
|
||||||
|
|
@ -52,7 +53,7 @@ namespace GC {
|
||||||
std::ofstream create_file_stream();
|
std::ofstream create_file_stream();
|
||||||
std::string get_log_folder();
|
std::string get_log_folder();
|
||||||
static void dump_trace();
|
static void dump_trace();
|
||||||
static void dump_prof_trace();
|
static void dump_prof_trace(bool timing_only);
|
||||||
static void dump_chunk_trace();
|
static void dump_chunk_trace();
|
||||||
// static void dump_trace_short();
|
// static void dump_trace_short();
|
||||||
// static void dump_trace_full();
|
// static void dump_trace_full();
|
||||||
|
|
|
||||||
|
|
@ -288,23 +288,7 @@ namespace GC
|
||||||
stack_bottom++;
|
stack_bottom++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterates through the stack, if an element on the stack points to a chunk,
|
|
||||||
* called a root chunk, that chunk is marked (i.e. reachable).
|
|
||||||
* Then it recursively follows all chunks which are possibly reachable from
|
|
||||||
* the root chunk and mark those chunks.
|
|
||||||
* If a chunk is marked it is removed from the worklist, since it's no longer of
|
|
||||||
* concern for this method.
|
|
||||||
*
|
|
||||||
* Time complexity: 0(N^2 * log(N)) as upper bound.
|
|
||||||
* Where N is either the size of the worklist or the size of
|
|
||||||
* the stack frame, depending on which is the largest.
|
|
||||||
*
|
|
||||||
* @param start Pointer to the start of the stack frame.
|
|
||||||
* @param end Pointer to the end of the stack frame.
|
|
||||||
* @param worklist The currently allocated chunks, which haven't been marked.
|
|
||||||
*/
|
|
||||||
void Heap::mark(vector<uintptr_t *> &roots)
|
void Heap::mark(vector<uintptr_t *> &roots)
|
||||||
{
|
{
|
||||||
bool prof_enabled = m_profiler_enable;
|
bool prof_enabled = m_profiler_enable;
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,10 @@ namespace GC
|
||||||
void Profiler::dump_trace()
|
void Profiler::dump_trace()
|
||||||
{
|
{
|
||||||
Profiler &prof = Profiler::the();
|
Profiler &prof = Profiler::the();
|
||||||
if (prof.flags & FunctionCalls)
|
if (prof.flags == TimingInfo)
|
||||||
dump_prof_trace();
|
dump_prof_trace(true);
|
||||||
|
else if (prof.flags & FunctionCalls)
|
||||||
|
dump_prof_trace(false);
|
||||||
else
|
else
|
||||||
dump_chunk_trace();
|
dump_chunk_trace();
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +129,7 @@ namespace GC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profiler::dump_prof_trace()
|
void Profiler::dump_prof_trace(bool timing_only)
|
||||||
{
|
{
|
||||||
Profiler &prof = Profiler::the();
|
Profiler &prof = Profiler::the();
|
||||||
prof.m_prof_events.push_back(prof.m_last_prof_event);
|
prof.m_prof_events.push_back(prof.m_last_prof_event);
|
||||||
|
|
@ -147,9 +149,12 @@ namespace GC
|
||||||
else if (event->m_type == CollectStart)
|
else if (event->m_type == CollectStart)
|
||||||
collects += event->m_n;
|
collects += event->m_n;
|
||||||
|
|
||||||
fstr << "\n--------------------------------\n"
|
if (!timing_only)
|
||||||
|
{
|
||||||
|
fstr << "\n--------------------------------\n"
|
||||||
<< Profiler::type_to_string(event->m_type) << " "
|
<< Profiler::type_to_string(event->m_type) << " "
|
||||||
<< event->m_n << " times:";
|
<< event->m_n << " times:";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fstr << "\n--------------------------------";
|
fstr << "\n--------------------------------";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,83 +32,21 @@ Node *create_list(size_t length)
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_list(Node* head)
|
|
||||||
{
|
|
||||||
cout << "\nPrinting list...\n";
|
|
||||||
while (head != nullptr)
|
|
||||||
{
|
|
||||||
cout << head->value << " ";
|
|
||||||
head = head->next;
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_list(Node *head)
|
|
||||||
{
|
|
||||||
while (head != nullptr)
|
|
||||||
{
|
|
||||||
Node *tmp = head->next;
|
|
||||||
head->next = nullptr;
|
|
||||||
head = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LIST_SIZE 1000
|
#define LIST_SIZE 1000
|
||||||
|
|
||||||
void list_test1()
|
void list_test1()
|
||||||
{
|
{
|
||||||
Node *list_1 = create_list(LIST_SIZE);
|
Node *list_1 = create_list(LIST_SIZE);
|
||||||
// print_list(list_1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void list_test2()
|
|
||||||
{
|
|
||||||
Node *list_2 = create_list(LIST_SIZE);
|
|
||||||
// print_list(list_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void list_test3()
|
|
||||||
{
|
|
||||||
Node *list_3 = create_list(LIST_SIZE);
|
|
||||||
// print_list(list_3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void list_test4()
|
|
||||||
{
|
|
||||||
Node *list_4 = create_list(LIST_SIZE);
|
|
||||||
// print_list(list_4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void list_test5()
|
|
||||||
{
|
|
||||||
Node *list_5 = create_list(LIST_SIZE);
|
|
||||||
// print_list(list_5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void list_test6()
|
|
||||||
{
|
|
||||||
Node *list_6 = create_list(LIST_SIZE);
|
|
||||||
// print_list(list_6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void make_test() {
|
|
||||||
list_test1();
|
|
||||||
list_test2();
|
|
||||||
list_test3();
|
|
||||||
list_test4();
|
|
||||||
list_test5();
|
|
||||||
list_test6();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
GC::Heap::init();
|
GC::Heap::init();
|
||||||
GC::Heap &heap = GC::Heap::the();
|
GC::Heap &heap = GC::Heap::the();
|
||||||
heap.set_profiler(true);
|
heap.set_profiler(true);
|
||||||
GC::Profiler::set_log_options(GC::FunctionCalls);
|
// GC::Profiler::set_log_options(GC::FunctionCalls);
|
||||||
//GC::Profiler::set_log_options(GC::AllOps);
|
// GC::Profiler::set_log_options(GC::ChunkOps);
|
||||||
|
GC::Profiler::set_log_options(GC::TimingInfo);
|
||||||
|
|
||||||
// make_test();
|
// make_test();
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue