-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
monitoringName
to memoized functionsavgFnTime
calculationavgFnTime
equal to zero, while it should be equal to at least the first function call time.getEmojiUnicode
getLocaleDigits
usagegetUnreadReportsForUnreadIndicator
performancefreezeScreenWithLazyLoading
monitoringName
.Fixed Issues
$ #48319
PROPOSAL: #48319 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop