-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Report single MissingTree
instead of large MissingFieldError[]
array for incomplete cache reads
#8734
Report single MissingTree
instead of large MissingFieldError[]
array for incomplete cache reads
#8734
Conversation
In this comment I confirmed that this PR fixes my issue: #8707 (comment). Thanks again! |
0125b55
to
4203a8a
Compare
@@ -241,6 +230,7 @@ export class StoreReader { | |||
}; | |||
|
|||
const rootRef = makeReference(rootId); | |||
const merger = new DeepMerger; |
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.
I thought TypeScript hated it when you invoke a constructor without parens.
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.
Can we get a comment about why we’re using DeepMerger
directly over calling mergeDeep
? Is there some kind of stateful thing going on here?
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.
Yes (to both)! b4c9a65
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.
Looks good!
In the (somewhat pathological but also entirely plausible) example in #8707, more than 60% of cache read time is spent creating
MissingFieldError
objects, in part because an unnecessaryInvariantError
is created and then used only for itsmessage
; in part because theMissingFieldError
class inherits fromError
, which makessuper(message)
initialization expensive; but also (in large part) because there are just so many error objects (tens of thousands).This pull request needs more work to minimize breaking changes for anyone using the
MissingFieldError
type directly, but it offers an extremely appealing solution to the performance problems enumerated above: What if we reported only one, combinedMissingFieldError
per cache read?On a personal note, I'm leaving for a weeklong vacation today, so I don't need this reviewed any time soon. 🏝