From 42d45cfd0c3d62357a6549c62f535e4d4fe08d91 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Wed, 2 May 2012 10:34:47 -0700 Subject: Update fast mixer statistics Compute statistics on fast mixer elapsed time and CPU load per cycle using a simple moving average rather than by fixed blocks. This has a couple advantages: - remove burstiness of CPU usage due to former floating-point calculations in fast mixer - gives us flexibility in how to report (e.g. could report over just the last 1 second) Disadvantage is increased RAM, and since the samples are not updated atomically, it is possible to have an error in the statistics. This should not be much of an issue due to the relatively large number of samples. Also add CPU raw ns and adjusted MHz statistics. Change-Id: Iaa2cd13f18250c3162aff40409b3694b769d9505 --- services/audioflinger/FastMixer.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'services/audioflinger/FastMixer.h') diff --git a/services/audioflinger/FastMixer.h b/services/audioflinger/FastMixer.h index a6dd310..e2ed553 100644 --- a/services/audioflinger/FastMixer.h +++ b/services/audioflinger/FastMixer.h @@ -64,7 +64,7 @@ struct FastMixerDumpState { FastMixerDumpState(); /*virtual*/ ~FastMixerDumpState(); - void dump(int fd); + void dump(int fd); // should only be called on a stable copy, not the original FastMixerState::Command mCommand; // current command uint32_t mWriteSequence; // incremented before and after each write() @@ -78,12 +78,20 @@ struct FastMixerDumpState { struct timespec mMeasuredWarmupTs; // measured warmup time uint32_t mWarmupCycles; // number of loop cycles required to warmup FastTrackDump mTracks[FastMixerState::kMaxFastTracks]; + #ifdef FAST_MIXER_STATISTICS - // cycle times in seconds - float mMean; - float mMinimum; - float mMaximum; - float mStddev; + // Recently collected samples of per-cycle monotonic time, thread CPU time, and CPU frequency. + // kSamplingN is the size of the sampling frame, and must be a power of 2 <= 0x8000. + static const uint32_t kSamplingN = 0x1000; + // The bounds define the interval of valid samples, and are represented as follows: + // newest open (excluded) endpoint = lower 16 bits of bounds, modulo N + // oldest closed (included) endpoint = upper 16 bits of bounds, modulo N + // Number of valid samples is newest - oldest. + uint32_t mBounds; // bounds for mMonotonicNs, mThreadCpuNs, and mCpukHz + // The elements in the *Ns arrays are in units of nanoseconds <= 3999999999. + uint32_t mMonotonicNs[kSamplingN]; // delta monotonic (wall clock) time + uint32_t mLoadNs[kSamplingN]; // delta CPU load in time + uint32_t mCpukHz[kSamplingN]; // absolute CPU clock frequency in kHz, bits 0-3 are CPU# #endif }; -- cgit v1.1