[NoQA] Memoize: Fix debugging stats issues#48322
Conversation
|
@ishpaul777 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@ishpaul777 This PR is not yet ready for review, sorry for the miss-click! |
|
After trying to follow Jason's flow and exploring different parts of the app, I've noticed:
Cache dump[
{
"id": "NumberFormatUtils",
"stats": {
"calls": 1813,
"hits": 1803,
"avgCacheRetrievalTime": 0.0023205953239618595,
"avgFnTime": 0.06000000089406967,
"cacheSize": 10
}
},
{
"id": "getLocaleDigits",
"stats": {
"calls": 183,
"hits": 182,
"avgCacheRetrievalTime": 0.004395604297354978,
"avgFnTime": 0.29999999701976776,
"cacheSize": 1
}
},
{
"id": "getEmojiUnicode",
"stats": {
"calls": 704,
"hits": 685,
"avgCacheRetrievalTime": 0.0017099554950169378,
"avgFnTime": 0.01578947431162784,
"cacheSize": 19
}
},
{
"id": "getUnreadReportsForUnreadIndicator",
"stats": {
"calls": 36,
"hits": 24,
"avgCacheRetrievalTime": 2.592046599053531,
"avgFnTime": 0.6083333355685075,
"cacheSize": 12
}
}
]
|
|
We might also adjust (or add another) timing for Currently it measure the time for cache itself but not for the entire memoize overhead, which might be insightful. We either can add Line 67 in b912e17 |
After investigating, the first call is registered properly. What is happening is that monitoring was enabled after initial function call was made, so the function call timing could not be registered and all subsequent calls were intercepted by the cache, so we ended up with zero value for fnTime. |
|
Status update: #48319 (comment) |
a5bc6aa to
3574d9d
Compare
|
Cache retrieval time stat was changed as follows: Retrieval time adjustmentsIn the This should contribute to more precise timings. Before const statsEntry = stats.createEntry();
// Detect if memoized function was called with `new` keyword. If so we need to call the original function as constructor.
const constructable = !!new.target;
const truncatedArgs = truncateArgs(args, options.maxArgs);
const key = options.transformKey ? options.transformKey(truncatedArgs) : (truncatedArgs as Key);
const retrievalTimeStart = performance.now();After const statsEntry = stats.createEntry();
const retrievalTimeStart = performance.now();
// Detect if memoized function was called with `new` keyword. If so we need to call the original function as constructor.
const constructable = !!new.target;
const truncatedArgs = truncateArgs(args, options.maxArgs);
const key = options.transformKey ? options.transformKey(truncatedArgs) : (truncatedArgs as Key);fnTime and retrievalTime unification at stat entry levelIn order to remove some complexity, the |
|
@ishpaul777 The PR is ready to be reviewed now :) CC @mountiny |
mountiny
left a comment
There was a problem hiding this comment.
Changes look good to me, not sure if we need a c+ review on this one
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
Thanks for the investigation, looks good to me |
|
@mountiny looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Hmm checklists are filled in, not an emergency |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.28-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.28-3 🚀
|
Details
monitoringNameto memoized functionsavgFnTimecalculationavgFnTimeequal to zero, while it should be equal to at least the first function call time.getEmojiUnicodegetLocaleDigitsusagegetUnreadReportsForUnreadIndicatorperformancefreezeScreenWithLazyLoadingmonitoringName.Fixed Issues
$ #48319
PROPOSAL: #48319 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop