diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index fbffe133f12e93260982c1844bb1cb044dd438c6..a7adcc672929ea1380ac80a09d2d7a5c41804eef 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -176,11 +176,14 @@ TimeBlockTreeNode& TimeBlock::getTreeNode() const TimeBlockTreeNode* nodep = LLTrace::get_thread_recorder()->getTimeBlockTreeNode(getIndex()); llassert(nodep); return *nodep; - } +} + +static LLFastTimer::DeclareTimer FTM_PROCESS_TIMES("Process FastTimer Times"); //static void TimeBlock::processTimes() { + LLFastTimer _(FTM_PROCESS_TIMES); get_clock_count(); // good place to calculate clock frequency U64 cur_time = getCPUClockCount64(); @@ -329,12 +332,12 @@ void TimeBlock::logStats() { TimeBlock& timer = *it; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); - sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecordingPeriod().getSum(timer).value()); - sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecordingPeriod().getSum(timer.callCount())); + sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecording().getSum(timer).value()); + sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecording().getSum(timer.callCount())); // computing total time here because getting the root timer's getCountHistory // doesn't work correctly on the first frame - total_time += frame_recording.getLastRecordingPeriod().getSum(timer); + total_time += frame_recording.getLastRecording().getSum(timer); } } @@ -353,7 +356,7 @@ void TimeBlock::logStats() void TimeBlock::dumpCurTimes() { LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); // walk over timers in depth order and output timings for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimeBlock()); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f78b7942a7fe139f82be675ef10ee02ff8a36676..21156b4d619aed2be507ab760215388a3a7e357b 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -360,8 +360,7 @@ U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& st PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), - mCurPeriod(0), - mTotalValid(false) + mCurPeriod(0) { if (num_periods) { @@ -373,7 +372,7 @@ PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) void PeriodicRecording::nextPeriod() { EPlayState play_state = getPlayState(); - Recording& old_recording = getCurRecordingPeriod(); + Recording& old_recording = getCurRecording(); if (mAutoResize) { mRecordingPeriods.push_back(Recording()); @@ -382,87 +381,59 @@ void PeriodicRecording::nextPeriod() mCurPeriod = (num_periods > 0) ? (mCurPeriod + 1) % num_periods : mCurPeriod + 1; - old_recording.splitTo(getCurRecordingPeriod()); + old_recording.splitTo(getCurRecording()); switch(play_state) { case STOPPED: - getCurRecordingPeriod().stop(); + getCurRecording().stop(); break; case PAUSED: - getCurRecordingPeriod().pause(); + getCurRecording().pause(); break; case STARTED: break; } - // new period, need to recalculate total - mTotalValid = false; -} - -Recording& PeriodicRecording::getTotalRecording() -{ - if (!mTotalValid) - { - mTotalRecording.reset(); - U32 num_periods = mRecordingPeriods.size(); - - if (num_periods) - { - for (S32 i = mCurPeriod + 1; i < mCurPeriod + num_periods; i++) - { - mTotalRecording.appendRecording(mRecordingPeriods[i % num_periods]); - } - } - else - { - for (S32 i = 0; i < mCurPeriod; i++) - { - mTotalRecording.appendRecording(mRecordingPeriods[i]); - } - } - } - mTotalValid = true; - return mTotalRecording; } void PeriodicRecording::start() { - getCurRecordingPeriod().start(); + getCurRecording().start(); } void PeriodicRecording::stop() { - getCurRecordingPeriod().stop(); + getCurRecording().stop(); } void PeriodicRecording::pause() { - getCurRecordingPeriod().pause(); + getCurRecording().pause(); } void PeriodicRecording::resume() { - getCurRecordingPeriod().resume(); + getCurRecording().resume(); } void PeriodicRecording::restart() { - getCurRecordingPeriod().restart(); + getCurRecording().restart(); } void PeriodicRecording::reset() { - getCurRecordingPeriod().reset(); + getCurRecording().reset(); } void PeriodicRecording::splitTo(PeriodicRecording& other) { - getCurRecordingPeriod().splitTo(other.getCurRecordingPeriod()); + getCurRecording().splitTo(other.getCurRecording()); } void PeriodicRecording::splitFrom(PeriodicRecording& other) { - getCurRecordingPeriod().splitFrom(other.getCurRecordingPeriod()); + getCurRecording().splitFrom(other.getCurRecording()); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index b96d0666e506b0a4ff4a030c3ac869d1fbf7f1ab..0a3e9e5a0b6846b4a50374786de42f3ed486a862 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -254,50 +254,48 @@ namespace LLTrace void nextPeriod(); U32 getNumPeriods() { return mRecordingPeriods.size(); } - Recording& getLastRecordingPeriod() + Recording& getLastRecording() { U32 num_periods = mRecordingPeriods.size(); return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; } - const Recording& getLastRecordingPeriod() const + const Recording& getLastRecording() const { - return getPrevRecordingPeriod(1); + return getPrevRecording(1); } - Recording& getCurRecordingPeriod() + Recording& getCurRecording() { return mRecordingPeriods[mCurPeriod]; } - const Recording& getCurRecordingPeriod() const + const Recording& getCurRecording() const { return mRecordingPeriods[mCurPeriod]; } - Recording& getPrevRecordingPeriod(U32 offset) + Recording& getPrevRecording(U32 offset) { U32 num_periods = mRecordingPeriods.size(); offset = llclamp(offset, 0u, num_periods - 1); return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } - const Recording& getPrevRecordingPeriod(U32 offset) const + const Recording& getPrevRecording(U32 offset) const { U32 num_periods = mRecordingPeriods.size(); offset = llclamp(offset, 0u, num_periods - 1); return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } - Recording snapshotCurRecordingPeriod() const + Recording snapshotCurRecording() const { - Recording recording_copy(getCurRecordingPeriod()); + Recording recording_copy(getCurRecording()); recording_copy.stop(); return recording_copy; } - Recording& getTotalRecording(); - template <typename T> typename T::value_t getPeriodMin(const TraceType<T>& stat) const { @@ -391,7 +389,6 @@ namespace LLTrace private: std::vector<Recording> mRecordingPeriods; Recording mTotalRecording; - bool mTotalValid; const bool mAutoResize; S32 mCurPeriod; }; diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d9f3d14ef0c3779c54b1e664b6dce9800ad8f43d..46eea368e51ad367e9bb38578e28dcb059b037ba 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -103,12 +103,11 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; - S32 num_samples = 0; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); if (mCountFloatp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); if (mPerSec) { @@ -116,7 +115,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountFloatp); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } else { @@ -124,12 +122,11 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp); max = frame_recording.getPeriodMax(*mCountFloatp); mean = frame_recording.getPeriodMean(*mCountFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } } else if (mCountIntp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); if (mPerSec) { @@ -137,7 +134,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountIntp); max = frame_recording.getPeriodMaxPerSec(*mCountIntp); mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } else { @@ -145,26 +141,25 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountIntp); max = frame_recording.getPeriodMax(*mCountIntp); mean = frame_recording.getPeriodMean(*mCountIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } } else if (mMeasurementFloatp) { - LLTrace::Recording& recording = frame_recording.getTotalRecording(); - current = recording.getLastValue(*mMeasurementFloatp); - min = recording.getMin(*mMeasurementFloatp); - max = recording.getMax(*mMeasurementFloatp); - mean = recording.getMean(*mMeasurementFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementFloatp); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mMeasurementFloatp); + min = frame_recording.getPeriodMin(*mMeasurementFloatp); + max = frame_recording.getPeriodMax(*mMeasurementFloatp); + mean = frame_recording.getPeriodMean(*mMeasurementFloatp); } else if (mMeasurementIntp) { - LLTrace::Recording& recording = frame_recording.getTotalRecording(); - current = recording.getLastValue(*mMeasurementIntp); - min = recording.getMin(*mMeasurementIntp); - max = recording.getMax(*mMeasurementIntp); - mean = recording.getMean(*mMeasurementIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementIntp); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mMeasurementIntp); + min = frame_recording.getPeriodMin(*mMeasurementIntp); + max = frame_recording.getPeriodMax(*mMeasurementIntp); + mean = frame_recording.getPeriodMean(*mMeasurementIntp); } current *= mUnitScale; @@ -203,7 +198,7 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if (mScaleRange && num_samples) + if (mScaleRange && min < max) { F32 cur_max = mTickSpacing; while(max > cur_max && mMaxBar > cur_max) @@ -352,7 +347,7 @@ void LLStatBar::draw() for (i = 1; i <= max_frame; i++) { F32 offset = ((F32)i / (F32)mNumFrames) * span; - LLTrace::Recording& recording = frame_recording.getPrevRecordingPeriod(i); + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); if (mPerSec) { if (mCountFloatp) diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index bdb378c9c54c0cf90e6bf3a3c44f52d22c4b308b..af01e66095cc720c121dc42e1ed01b1907d0401a 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -66,7 +66,7 @@ void LLStatGraph::draw() range = mMax - mMin; if (mNewStatFloatp) { - LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecording(); if (mPerSec) { @@ -79,7 +79,7 @@ void LLStatGraph::draw() } else if (mNewStatIntp) { - LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecording(); if (mPerSec) { diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 420220d21a2601a28a1e46a98289e41996caedad..7c9fbccd7fb8cd08feb0273606967b0a429a3cc8 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1082,7 +1082,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation(); LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation(); - if (LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f + if (LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f && (root_at * last_at_axis > 0.95f)) { LLVector3 vel = gAgentAvatarp->getVelocity(); diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 80d845c70ea2a1bf6f31c42baf048bffaf3b1cab..45ffe56ac136265e42fc31f2cda5ab7209c8f0c1 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -333,7 +333,7 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); } return tooltip; } @@ -417,7 +417,7 @@ void LLFastTimerView::draw() printLineStats(); LLView::draw(); - mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(FTM_FRAME)); + mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecording().getSum(FTM_FRAME)); mHoverID = NULL; mHoverBarIndex = -1; } @@ -984,7 +984,7 @@ void LLFastTimerView::printLineStats() LLUnit<LLUnits::Seconds, F32> ticks; if (mPrintStats > 0) { - ticks = mRecording->getPrevRecordingPeriod(mPrintStats).getSum(*idp); + ticks = mRecording->getPrevRecording(mPrintStats).getSum(*idp); } else { @@ -1096,8 +1096,8 @@ void LLFastTimerView::drawLineGraph() j > 0; j--) { - LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001)); - U32 calls = mRecording->getPrevRecordingPeriod(j).getSum(idp->callCount()); + LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecording(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001)); + U32 calls = mRecording->getPrevRecording(j).getSum(idp->callCount()); if (alpha == 1.f) { @@ -1197,8 +1197,8 @@ void LLFastTimerView::drawLegend( S32 y ) if (mHoverBarIndex > 0 && mHoverID) { S32 hidx = mScrollIndex + mHoverBarIndex; - ms = mRecording->getPrevRecordingPeriod(hidx).getSum(*idp); - calls = mRecording->getPrevRecordingPeriod(hidx).getSum(idp->callCount()); + ms = mRecording->getPrevRecording(hidx).getSum(*idp); + calls = mRecording->getPrevRecording(hidx).getSum(idp->callCount()); } else { @@ -1455,7 +1455,7 @@ S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::v LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); F32 self_time_frame_fraction = history_index == -1 ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) - : (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); + : (mRecording->getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); S32 full_width = self_time_width; diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 58701ca3c91d4af0f797391f0e1da2042c1df19e..93502daac732eb885aae73334e3461a0db7513cb 100644 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -296,7 +296,7 @@ LLSD LLFloaterAbout::getInfo() if (gPacketsIn > 0) { - LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecordingPeriod(); + LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecording(); info["PACKETS_LOST"] = cur_frame.getSum(LLStatViewer::PACKETS_LOST); info["PACKETS_IN"] = F32(gPacketsIn); info["PACKETS_PCT"] = 100.f*info["PACKETS_LOST"].asReal() / info["PACKETS_IN"].asReal(); diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 3ac11f906b0854361214a00d255c2c404116537c..cdfe7765891b5c05defe0ec1b7d83ff666e4f53e 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -901,7 +901,7 @@ void LLHUDNameTag::updateAll() } LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat(); - F32 camera_vel = LLTrace::get_frame_recording().getLastRecordingPeriod().getPerSec(*camera_vel_stat); + F32 camera_vel = LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat); if (camera_vel > MAX_STABLE_CAMERA_VELOCITY) { return; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index fa4eb73180ed875fa36917eac1153f2c79bb4c19..13a005dcbfbf0242a61f8cc2ea543ba3236d155c 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -348,11 +348,12 @@ void update_statistics() sample(LLStatViewer::SIM_PING, LLTrace::Seconds(10)); } - add(LLStatViewer::FPS, 1); - if (LLTrace::get_frame_recording().getTotalRecording().getSampleCount(LLStatViewer::FPS)) + if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS)) { - sample(LLStatViewer::FPS_SAMPLE, LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS)); + sample(LLStatViewer::FPS_SAMPLE, LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::FPS)); } + add(LLStatViewer::FPS, 1); + F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); add(LLStatViewer::LAYERS_KBIT, LLTrace::Bits(layer_bits)); add(LLStatViewer::OBJECT_KBIT, gObjectData); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 0066c0972012cd6ab2ff2d80ad102d4e7a89d360..1bb4041bbdc699dfd8ed47095ae32e0b4f5df2ce 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -617,9 +617,7 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording(); - - LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value()); + LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_KBIT).value()); { using namespace LLStatViewer; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 26ceaf512a058d36a801ff55ee5a7c7617aed8d6..1b5148e560b394ed203adbbe81de9da3be2f682b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9816,7 +9816,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0); + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); //update shadow targets for (U32 i = 0; i < 2; i++)