From f93da44ee5c9131ce4904258e30d1d93e6aa188b Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH] Remove idb device polling record Summary: If listing devices is successful, then don't record the event as this is triggered every X amount of seconds. Reviewed By: antonk52 Differential Revision: D47995681 fbshipit-source-id: 2d0fa68fd7b9c4ce74bad9e8cc0296691d9b8880 --- .../src/devices/ios/iOSContainerUtility.tsx | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx index beeddcde8..935f36d60 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx @@ -28,6 +28,7 @@ export type IdbConfig = { // Use debug to get helpful logs when idb fails const IDB_LOG_LEVEL = 'DEBUG'; const LOG_TAG = 'iOSContainerUtility'; +const CMD_RECORD_THROTTLE_COUNT = 10; const mutex = new Mutex(); @@ -49,6 +50,10 @@ export type DeviceTarget = { name: string; }; +let idbDeviceListing = 0; +let idbCompanionDeviceListing = 0; +let xcodeDeviceListing = 0; + async function isAvailable(idbPath: string): Promise { if (!idbPath) { return false; @@ -88,12 +93,17 @@ async function queryTargetsWithXcode( }); throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + + xcodeDeviceListing++; + if (xcodeDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } + return stdout .toString() .split('\n') @@ -141,12 +151,15 @@ async function queryTargetsWithIdb( throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + idbDeviceListing++; + if (idbDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } return parseIdbTargets(stdout.toString()); } catch (e) { @@ -187,12 +200,15 @@ async function queryTargetsWithIdbCompanion( throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + idbCompanionDeviceListing++; + if (idbCompanionDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } const devices = parseIdbTargets(stdout.toString()); if (devices.length > 0 && !isPhysicalDeviceEnabled) {