make thread block time explicit in pstats

This commit is contained in:
David Rose 2007-07-01 18:48:50 +00:00
parent 6e9f58aa4b
commit 04a5308b57
3 changed files with 10 additions and 40 deletions

View File

@ -80,7 +80,7 @@ PStatCollector VertexDataPage::_vdata_compress_pcollector("*:Vertex Data:Compres
PStatCollector VertexDataPage::_vdata_decompress_pcollector("*:Vertex Data:Decompress");
PStatCollector VertexDataPage::_vdata_save_pcollector("*:Vertex Data:Save");
PStatCollector VertexDataPage::_vdata_restore_pcollector("*:Vertex Data:Restore");
PStatCollector VertexDataPage::_thread_wait_pcollector("*:Wait:Idle");
PStatCollector VertexDataPage::_thread_wait_pcollector("Wait:Idle");
PStatCollector VertexDataPage::_alloc_pages_pcollector("System memory:MMap:Vertex data");
TypeHandle VertexDataPage::_type_handle;

View File

@ -49,6 +49,7 @@ PStatCollector PStatClient::_mmap_dc_inactive_other_size_pcollector("System memo
PStatCollector PStatClient::_pstats_pcollector("*:PStats");
PStatCollector PStatClient::_clock_wait_pcollector("Wait:Clock Wait:Sleep");
PStatCollector PStatClient::_clock_busy_wait_pcollector("Wait:Clock Wait:Spin");
PStatCollector PStatClient::_thread_block_pcollector("Wait:Thread block");
PStatClient *PStatClient::_global_pstats = NULL;
@ -721,7 +722,6 @@ start(int collector_index, int thread_index) {
if (thread->_thread_active) {
thread->_frame_data.add_start(collector_index, get_real_time());
}
thread->_active_collectors.set_bit(collector_index);
}
collector->_per_thread[thread_index]._nested_count++;
}
@ -752,7 +752,6 @@ start(int collector_index, int thread_index, float as_of) {
if (thread->_thread_active) {
thread->_frame_data.add_start(collector_index, as_of);
}
thread->_active_collectors.set_bit(collector_index);
}
collector->_per_thread[thread_index]._nested_count++;
}
@ -795,7 +794,6 @@ stop(int collector_index, int thread_index) {
if (thread->_thread_active) {
thread->_frame_data.add_stop(collector_index, get_real_time());
}
thread->_active_collectors.clear_bit(collector_index);
}
}
}
@ -1091,27 +1089,14 @@ deactivate_hook(Thread *thread) {
if (_impl == NULL) {
return;
}
InternalThread *ithread = get_thread_ptr(thread->get_pstats_index());
int thread_index = thread->get_pstats_index();
InternalThread *ithread = get_thread_ptr(thread_index);
if (ithread->_thread_active) {
// Stop all of the active collectors for this thread.
// Start _thread_block_pcollector, by hand, being careful not to
// grab any mutexes while we do it.
double now = _impl->get_real_time();
int off_bit = -1;
int on_bit = ithread->_active_collectors.get_lowest_on_bit();
while (off_bit != on_bit) {
off_bit = ithread->_active_collectors.get_next_higher_different_bit(on_bit);
nassertd(off_bit != on_bit) {
cerr << "Oops! off_bit = " << off_bit
<< ", collectors = " << ithread->_active_collectors << "\n";
}
while (on_bit < off_bit) {
// Here's an active collector. Record a data point indicating
// it stops here.
ithread->_frame_data.add_stop(on_bit, now);
++on_bit;
}
on_bit = ithread->_active_collectors.get_next_higher_different_bit(off_bit);
}
ithread->_frame_data.add_start(_thread_block_pcollector.get_index(), now);
ithread->_thread_active = false;
}
}
@ -1137,24 +1122,8 @@ activate_hook(Thread *thread) {
InternalThread *ithread = get_thread_ptr(thread->get_pstats_index());
if (!ithread->_thread_active) {
// Resume all of the active collectors for this thread.
double now = _impl->get_real_time();
int off_bit = -1;
int on_bit = ithread->_active_collectors.get_lowest_on_bit();
while (off_bit != on_bit) {
off_bit = ithread->_active_collectors.get_next_higher_different_bit(on_bit);
nassertd(off_bit != on_bit) {
cerr << "Oops! off_bit = " << off_bit
<< ", collectors = " << ithread->_active_collectors << "\n";
}
while (on_bit < off_bit) {
// Here's an active collector. Record a data point indicating
// it resumes here.
ithread->_frame_data.add_start(on_bit, now);
++on_bit;
}
on_bit = ithread->_active_collectors.get_next_higher_different_bit(off_bit);
}
ithread->_frame_data.add_stop(_thread_block_pcollector.get_index(), now);
ithread->_thread_active = true;
}
}

View File

@ -213,7 +213,7 @@ private:
float _next_packet;
bool _thread_active;
BitArray _active_collectors;
BitArray _active_collectors; // no longer used.
// This mutex is used to protect writes to _frame_data for this
// particular thread, as well as writes to the _per_thread data
@ -243,6 +243,7 @@ private:
static PStatCollector _pstats_pcollector;
static PStatCollector _clock_wait_pcollector;
static PStatCollector _clock_busy_wait_pcollector;
static PStatCollector _thread_block_pcollector;
static PStatClient *_global_pstats;