Skip to content

Commit a72220c

Browse files
committed
chore: Remove unusued performance metrics system
1 parent b351fa5 commit a72220c

11 files changed

Lines changed: 2 additions & 259 deletions

File tree

lib/GlobalSettings.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/Onyx.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import OnyxUtils from './OnyxUtils';
2626
import logMessages from './logMessages';
2727
import type {Connection} from './OnyxConnectionManager';
2828
import connectionManager from './OnyxConnectionManager';
29-
import * as GlobalSettings from './GlobalSettings';
30-
import decorateWithMetrics from './metrics';
3129
import OnyxMerge from './OnyxMerge';
3230

3331
/** Initialize the store with actions and listening for storage events */
@@ -37,17 +35,11 @@ function init({
3735
evictableKeys = [],
3836
maxCachedKeysCount = 1000,
3937
shouldSyncMultipleInstances = !!global.localStorage,
40-
enablePerformanceMetrics = false,
4138
enableDevTools = true,
4239
skippableCollectionMemberIDs = [],
4340
ramOnlyKeys = [],
4441
snapshotMergeKeys = [],
4542
}: InitOptions): void {
46-
if (enablePerformanceMetrics) {
47-
GlobalSettings.setPerformanceMetricsEnabled(true);
48-
applyDecorators();
49-
}
50-
5143
initDevTools(enableDevTools);
5244

5345
Storage.init();
@@ -604,25 +596,5 @@ const Onyx = {
604596
registerLogger: Logger.registerLogger,
605597
};
606598

607-
function applyDecorators() {
608-
// We are reassigning the functions directly so that internal function calls are also decorated
609-
// @ts-expect-error Reassign
610-
connect = decorateWithMetrics(connect, 'Onyx.connect');
611-
// @ts-expect-error Reassign
612-
connectWithoutView = decorateWithMetrics(connectWithoutView, 'Onyx.connectWithoutView');
613-
// @ts-expect-error Reassign
614-
set = decorateWithMetrics(set, 'Onyx.set');
615-
// @ts-expect-error Reassign
616-
multiSet = decorateWithMetrics(multiSet, 'Onyx.multiSet');
617-
// @ts-expect-error Reassign
618-
merge = decorateWithMetrics(merge, 'Onyx.merge');
619-
// @ts-expect-error Reassign
620-
mergeCollection = decorateWithMetrics(mergeCollection, 'Onyx.mergeCollection');
621-
// @ts-expect-error Reassign
622-
update = decorateWithMetrics(update, 'Onyx.update');
623-
// @ts-expect-error Reassign
624-
clear = decorateWithMetrics(clear, 'Onyx.clear');
625-
}
626-
627599
export default Onyx;
628600
export type {OnyxUpdate, ConnectOptions, SetOptions};

lib/OnyxUtils.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import type {FastMergeOptions, FastMergeResult} from './utils';
3636
import utils from './utils';
3737
import type {DeferredTask} from './createDeferredTask';
3838
import createDeferredTask from './createDeferredTask';
39-
import * as GlobalSettings from './GlobalSettings';
40-
import decorateWithMetrics from './metrics';
4139
import type {StorageKeyValuePair} from './storage/providers/types';
4240
import logMessages from './logMessages';
4341

@@ -1906,54 +1904,6 @@ const OnyxUtils = {
19061904
isRamOnlyKey,
19071905
};
19081906

1909-
GlobalSettings.addGlobalSettingsChangeListener(({enablePerformanceMetrics}) => {
1910-
if (!enablePerformanceMetrics) {
1911-
return;
1912-
}
1913-
// We are reassigning the functions directly so that internal function calls are also decorated
1914-
1915-
// @ts-expect-error Reassign
1916-
initStoreValues = decorateWithMetrics(initStoreValues, 'OnyxUtils.initStoreValues');
1917-
// @ts-expect-error Complex type signature
1918-
get = decorateWithMetrics(get, 'OnyxUtils.get');
1919-
// @ts-expect-error Reassign
1920-
getAllKeys = decorateWithMetrics(getAllKeys, 'OnyxUtils.getAllKeys');
1921-
// @ts-expect-error Reassign
1922-
getCollectionKeys = decorateWithMetrics(getCollectionKeys, 'OnyxUtils.getCollectionKeys');
1923-
// @ts-expect-error Reassign
1924-
keysChanged = decorateWithMetrics(keysChanged, 'OnyxUtils.keysChanged');
1925-
// @ts-expect-error Reassign
1926-
keyChanged = decorateWithMetrics(keyChanged, 'OnyxUtils.keyChanged');
1927-
// @ts-expect-error Reassign
1928-
sendDataToConnection = decorateWithMetrics(sendDataToConnection, 'OnyxUtils.sendDataToConnection');
1929-
// @ts-expect-error Reassign
1930-
scheduleSubscriberUpdate = decorateWithMetrics(scheduleSubscriberUpdate, 'OnyxUtils.scheduleSubscriberUpdate');
1931-
// @ts-expect-error Reassign
1932-
scheduleNotifyCollectionSubscribers = decorateWithMetrics(scheduleNotifyCollectionSubscribers, 'OnyxUtils.scheduleNotifyCollectionSubscribers');
1933-
// @ts-expect-error Reassign
1934-
remove = decorateWithMetrics(remove, 'OnyxUtils.remove');
1935-
// @ts-expect-error Reassign
1936-
reportStorageQuota = decorateWithMetrics(reportStorageQuota, 'OnyxUtils.reportStorageQuota');
1937-
// @ts-expect-error Complex type signature
1938-
retryOperation = decorateWithMetrics(retryOperation, 'OnyxUtils.retryOperation');
1939-
// @ts-expect-error Reassign
1940-
broadcastUpdate = decorateWithMetrics(broadcastUpdate, 'OnyxUtils.broadcastUpdate');
1941-
// @ts-expect-error Reassign
1942-
initializeWithDefaultKeyStates = decorateWithMetrics(initializeWithDefaultKeyStates, 'OnyxUtils.initializeWithDefaultKeyStates');
1943-
// @ts-expect-error Complex type signature
1944-
multiGet = decorateWithMetrics(multiGet, 'OnyxUtils.multiGet');
1945-
// @ts-expect-error Reassign
1946-
tupleGet = decorateWithMetrics(tupleGet, 'OnyxUtils.tupleGet');
1947-
// @ts-expect-error Reassign
1948-
subscribeToKey = decorateWithMetrics(subscribeToKey, 'OnyxUtils.subscribeToKey');
1949-
// @ts-expect-error Reassign
1950-
setWithRetry = decorateWithMetrics(setWithRetry, 'OnyxUtils.setWithRetry');
1951-
// @ts-expect-error Reassign
1952-
multiSetWithRetry = decorateWithMetrics(multiSetWithRetry, 'OnyxUtils.multiSetWithRetry');
1953-
// @ts-expect-error Reassign
1954-
setCollectionWithRetry = decorateWithMetrics(setCollectionWithRetry, 'OnyxUtils.setCollectionWithRetry');
1955-
});
1956-
19571907
export type {OnyxMethod};
19581908
export default OnyxUtils;
19591909
export {clearOnyxUtilsInternals};

lib/dependencies/ModuleProxy.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

lib/dependencies/PerformanceProxy/index.native.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/dependencies/PerformanceProxy/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/metrics.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

lib/storage/index.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import PlatformStorage from './platforms';
44
import InstanceSync from './InstanceSync';
55
import MemoryOnlyProvider from './providers/MemoryOnlyProvider';
66
import type StorageProvider from './providers/types';
7-
import * as GlobalSettings from '../GlobalSettings';
8-
import decorateWithMetrics from '../metrics';
9-
107
let provider = PlatformStorage as StorageProvider<unknown>;
118
let shouldKeepInstancesSync = false;
129
let finishInitalization: (value?: unknown) => void;
@@ -209,23 +206,4 @@ const storage: Storage = {
209206
},
210207
};
211208

212-
GlobalSettings.addGlobalSettingsChangeListener(({enablePerformanceMetrics}) => {
213-
if (!enablePerformanceMetrics) {
214-
return;
215-
}
216-
217-
// Apply decorators
218-
storage.getItem = decorateWithMetrics(storage.getItem, 'Storage.getItem');
219-
storage.multiGet = decorateWithMetrics(storage.multiGet, 'Storage.multiGet');
220-
storage.setItem = decorateWithMetrics(storage.setItem, 'Storage.setItem');
221-
storage.multiSet = decorateWithMetrics(storage.multiSet, 'Storage.multiSet');
222-
storage.mergeItem = decorateWithMetrics(storage.mergeItem, 'Storage.mergeItem');
223-
storage.multiMerge = decorateWithMetrics(storage.multiMerge, 'Storage.multiMerge');
224-
storage.removeItem = decorateWithMetrics(storage.removeItem, 'Storage.removeItem');
225-
storage.removeItems = decorateWithMetrics(storage.removeItems, 'Storage.removeItems');
226-
storage.clear = decorateWithMetrics(storage.clear, 'Storage.clear');
227-
storage.getAllKeys = decorateWithMetrics(storage.getAllKeys, 'Storage.getAllKeys');
228-
storage.getAll = decorateWithMetrics(storage.getAll, 'Storage.getAll');
229-
});
230-
231209
export default storage;

lib/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,6 @@ type InitOptions = {
407407
*/
408408
shouldSyncMultipleInstances?: boolean;
409409

410-
/**
411-
* If enabled it will use the performance API to measure the time taken by Onyx operations.
412-
* @default false
413-
*/
414-
enablePerformanceMetrics?: boolean;
415-
416410
/**
417411
* If enabled, it will connect to Redux DevTools Extension for debugging.
418412
* This allows you to see all Onyx state changes in the Redux DevTools.

lib/useOnyx.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import OnyxCache, {TASK} from './OnyxCache';
55
import type {Connection} from './OnyxConnectionManager';
66
import connectionManager from './OnyxConnectionManager';
77
import OnyxUtils from './OnyxUtils';
8-
import * as GlobalSettings from './GlobalSettings';
98
import type {CollectionKeyBase, OnyxKey, OnyxValue} from './types';
109
import usePrevious from './usePrevious';
11-
import decorateWithMetrics from './metrics';
1210
import onyxSnapshotCache from './OnyxSnapshotCache';
1311
import useLiveRef from './useLiveRef';
1412

@@ -329,19 +327,11 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
329327
[key, options?.initWithStoredValues, options?.reuseConnection, checkEvictableKey],
330328
);
331329

332-
const getSnapshotDecorated = useMemo(() => {
333-
if (!GlobalSettings.isPerformanceMetricsEnabled()) {
334-
return getSnapshot;
335-
}
336-
337-
return decorateWithMetrics(getSnapshot, 'useOnyx.getSnapshot');
338-
}, [getSnapshot]);
339-
340330
useEffect(() => {
341331
checkEvictableKey();
342332
}, [checkEvictableKey]);
343333

344-
const result = useSyncExternalStore<UseOnyxResult<TReturnValue>>(subscribe, getSnapshotDecorated);
334+
const result = useSyncExternalStore<UseOnyxResult<TReturnValue>>(subscribe, getSnapshot);
345335

346336
return result;
347337
}

0 commit comments

Comments
 (0)