diff options
author | Etan Cohen <etancohen@google.com> | 2017-06-29 11:51:20 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2017-06-30 17:00:28 -0700 |
commit | dca9963c7292e17318f5ba0dee6c3683c7c9f941 (patch) | |
tree | 200fa18e146bf835d4615311d5fea13f2bffd61c /service | |
parent | f28f838f3fe502fff47bcb3098098556b167ed88 (diff) |
[AWARE] Add NDP (data-path) creation duration metrics
Collect information on how long it takes to create a NAN
data-path (NDP): starting from initiator request to confirm
or from responder getting a request to confirm.
Bug: 26565416
Test: unit tests passing
Change-Id: Idbc526df1bb94af88247e9780925d0c312101a3a
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java | 21 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareMetrics.java | 36 |
2 files changed, 50 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index 7e22e990a..601fc4429 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -40,6 +40,7 @@ import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Looper; import android.os.ServiceManager; +import android.os.SystemClock; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; @@ -277,7 +278,7 @@ public class WifiAwareDataPathStateManager { } mNetworkRequestsCache.remove(networkSpecifier); - mAwareMetrics.recordNdpStatus(reason, networkSpecifier.isOutOfBand()); + mAwareMetrics.recordNdpStatus(reason, networkSpecifier.isOutOfBand(), nnri.startTimestamp); } @@ -344,6 +345,7 @@ public class WifiAwareDataPathStateManager { nnri.state = AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_RESPOND_RESPONSE; nnri.ndpId = ndpId; nnri.interfaceName = selectInterfaceForRequest(nnri); + nnri.startTimestamp = SystemClock.elapsedRealtime(); mMgr.respondToDataPathRequest(true, ndpId, nnri.interfaceName, nnri.networkSpecifier.pmk, nnri.networkSpecifier.passphrase, nnri.networkSpecifier.isOutOfBand()); @@ -387,7 +389,8 @@ public class WifiAwareDataPathStateManager { + " failed responding"); mMgr.endDataPath(ndpId); mNetworkRequestsCache.remove(networkSpecifier); - mAwareMetrics.recordNdpStatus(reasonOnFailure, networkSpecifier.isOutOfBand()); + mAwareMetrics.recordNdpStatus(reasonOnFailure, networkSpecifier.isOutOfBand(), + nnri.startTimestamp); return; } @@ -495,7 +498,8 @@ public class WifiAwareDataPathStateManager { networkSpecifier, ndpId); nnri.networkAgent.sendNetworkInfo(networkInfo); - mAwareMetrics.recordNdpStatus(NanStatusType.SUCCESS, networkSpecifier.isOutOfBand()); + mAwareMetrics.recordNdpStatus(NanStatusType.SUCCESS, networkSpecifier.isOutOfBand(), + nnri.startTimestamp); mAwareMetrics.recordNdpCreation(nnri.uid, mNetworkRequestsCache); } else { if (DBG) { @@ -503,7 +507,8 @@ public class WifiAwareDataPathStateManager { + " rejected - reason=" + reason); } mNetworkRequestsCache.remove(networkSpecifier); - mAwareMetrics.recordNdpStatus(reason, networkSpecifier.isOutOfBand()); + mAwareMetrics.recordNdpStatus(reason, networkSpecifier.isOutOfBand(), + nnri.startTimestamp); } return networkSpecifier; @@ -562,7 +567,7 @@ public class WifiAwareDataPathStateManager { return; } mAwareMetrics.recordNdpStatus(NanStatusType.INTERNAL_FAILURE, - nnri.networkSpecifier.isOutOfBand()); + nnri.networkSpecifier.isOutOfBand(), nnri.startTimestamp); mMgr.endDataPath(nnri.ndpId); } @@ -668,6 +673,7 @@ public class WifiAwareDataPathStateManager { nnri.networkSpecifier.passphrase, nnri.networkSpecifier.isOutOfBand()); nnri.state = AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE; + nnri.startTimestamp = SystemClock.elapsedRealtime(); } else { if (nnri.state != AwareNetworkRequestInformation.STATE_RESPONDER_IDLE) { if (DBG) { @@ -838,6 +844,7 @@ public class WifiAwareDataPathStateManager { public int ndpId; public byte[] peerDataMac; public WifiAwareNetworkSpecifier networkSpecifier; + public long startTimestamp = 0; // request is made (initiator) / get request (responder) public WifiAwareNetworkAgent networkAgent; @@ -981,7 +988,9 @@ public class WifiAwareDataPathStateManager { peerDiscoveryMac == null ? "" : String.valueOf(HexEncoding.encode(peerDiscoveryMac))).append( ", ndpId=").append(ndpId).append(", peerDataMac=").append( - peerDataMac == null ? "" : String.valueOf(HexEncoding.encode(peerDataMac))); + peerDataMac == null ? "" + : String.valueOf(HexEncoding.encode(peerDataMac))).append( + "startTimestamp=").append(startTimestamp); return sb.toString(); } } diff --git a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java index 78ac8fac1..5001274d0 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java @@ -102,6 +102,13 @@ public class WifiAwareMetrics { private SparseIntArray mInBandNdpStatusData = new SparseIntArray(); private SparseIntArray mOutOfBandNdpStatusData = new SparseIntArray(); + private SparseIntArray mNdpCreationTimeDuration = new SparseIntArray(); + private long mNdpCreationTimeMin = -1; + private long mNdpCreationTimeMax = 0; + private long mNdpCreationTimeSum = 0; + private long mNdpCreationTimeSumSq = 0; + private long mNdpCreationTimeNumSamples = 0; + public WifiAwareMetrics(Clock clock) { mClock = clock; } @@ -366,13 +373,25 @@ public class WifiAwareMetrics { * a failure on any aborts the process and is recorded. A success on intermediate stages is * not recorded - only the final success. */ - public void recordNdpStatus(int status, boolean isOutOfBand) { + public void recordNdpStatus(int status, boolean isOutOfBand, long startTimestamp) { synchronized (mLock) { if (isOutOfBand) { mOutOfBandNdpStatusData.put(status, mOutOfBandNdpStatusData.get(status) + 1); } else { mInBandNdpStatusData.put(status, mOutOfBandNdpStatusData.get(status) + 1); } + + if (status == NanStatusType.SUCCESS) { + long creationTime = mClock.getElapsedSinceBootMillis() - startTimestamp; + addLogValueToHistogram(creationTime, mNdpCreationTimeDuration, + DURATION_LOG_HISTOGRAM); + mNdpCreationTimeMin = (mNdpCreationTimeMin == -1) ? creationTime : Math.min( + mNdpCreationTimeMin, creationTime); + mNdpCreationTimeMax = Math.max(mNdpCreationTimeMax, creationTime); + mNdpCreationTimeSum += creationTime; + mNdpCreationTimeSumSq += creationTime * creationTime; + mNdpCreationTimeNumSamples += 1; + } } } @@ -435,6 +454,14 @@ public class WifiAwareMetrics { log.maxConcurrentNdpPerNdi = mMaxNdpPerNdi; log.histogramRequestNdpStatus = histogramToProtoArray(mInBandNdpStatusData); log.histogramRequestNdpOobStatus = histogramToProtoArray(mOutOfBandNdpStatusData); + + log.histogramNdpCreationTimeMs = histogramToProtoArray(mNdpCreationTimeDuration, + DURATION_LOG_HISTOGRAM); + log.ndpCreationTimeMsMin = mNdpCreationTimeMin; + log.ndpCreationTimeMsMax = mNdpCreationTimeMax; + log.ndpCreationTimeMsSum = mNdpCreationTimeSum; + log.ndpCreationTimeMsSumOfSq = mNdpCreationTimeSumSq; + log.ndpCreationTimeMsNumSamples = mNdpCreationTimeNumSamples; } return log; } @@ -484,6 +511,13 @@ public class WifiAwareMetrics { mMaxNdpPerNdi = 0; mInBandNdpStatusData.clear(); mOutOfBandNdpStatusData.clear(); + + mNdpCreationTimeDuration.clear(); + mNdpCreationTimeMin = -1; + mNdpCreationTimeMax = 0; + mNdpCreationTimeSum = 0; + mNdpCreationTimeSumSq = 0; + mNdpCreationTimeNumSamples = 0; } } |