Skip to content

Commit

Permalink
Test performance impact of inlining the prefix
Browse files Browse the repository at this point in the history
Reviewed By: lynnshaoyu

Differential Revision: D69672718

fbshipit-source-id: 56dbf840caa6075014e3bc2c84df73d0dfb96470
  • Loading branch information
tyao1 authored and facebook-github-bot committed Feb 20, 2025
1 parent 7b68e1f commit 9d556e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react-relay/__tests__/LiveResolvers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ describe('client-only fragments', () => {
expect(() => {
GLOBAL_STORE.dispatch({type: 'INCREMENT'});
}).toThrowError(
'Unexpected LiveState value returned from Relay Resolver internal field `RELAY_RESOLVER_LIVE_STATE_VALUE`. It is likely a bug in Relay, or a corrupt state of the relay store state Field Path `counter_suspends_when_odd`. Record `{"__id":"client:1:counter_suspends_when_odd","__typename":"__RELAY_RESOLVER__","__resolverError":null,"__resolverValue":{"__LIVE_RESOLVER_SUSPENSE_SENTINEL":true},"__resolverLiveStateDirty":true}`.',
'Unexpected LiveState value returned from Relay Resolver internal field `RELAY_RESOLVER_LIVE_STATE_VALUE`. It is likely a bug in Relay, or a corrupt state of the relay store state Field Path `counter_suspends_when_odd`. Record `{"__id":"client:1:$r:counter_suspends_when_odd","__typename":"__RELAY_RESOLVER__","__resolverError":null,"__resolverValue":{"__LIVE_RESOLVER_SUSPENSE_SENTINEL":true},"__resolverLiveStateDirty":true}`.',
);
// $FlowFixMe[incompatible-use]
expect(renderer.toJSON()).toEqual('Loading...');
Expand Down
4 changes: 2 additions & 2 deletions packages/relay-runtime/store/RelayStoreUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ERRORS_KEY: '__errors' = '__errors';
const MODULE_COMPONENT_KEY_PREFIX = '__module_component_';
const MODULE_OPERATION_KEY_PREFIX = '__module_operation_';

const RELAY_READ_TIME_RESOLVER_KEY_PREFIX = ''; // Set to empty string temporarily to test perf impact of appending prefix
const RELAY_READ_TIME_RESOLVER_KEY_PREFIX = '$r:';

function getArgumentValue(
arg: NormalizationArgument | ReaderArgument,
Expand Down Expand Up @@ -186,7 +186,7 @@ function getReadTimeResolverStorageKey(
): string {
const storageKey = getStorageKey(field, variables);
return RelayFeatureFlags.ENABLE_READ_TIME_RESOLVER_STORAGE_KEY_PREFIX
? RELAY_READ_TIME_RESOLVER_KEY_PREFIX + storageKey
? '$r:' + storageKey // Using inlined string to test the performance impact
: storageKey;
}

Expand Down

0 comments on commit 9d556e7

Please sign in to comment.