-
Notifications
You must be signed in to change notification settings - Fork 894
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
Memory LRU GC #6943
Memory LRU GC #6943
Conversation
🦋 Changeset detectedLatest commit: 85483bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (729,651 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
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.
A few tweaks to the public doc comments, thanks!
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.
LGTM with comments
* | ||
* This collector tries to ensure lowest memory footprints from the SDK, | ||
* at the risk of querying backend repeated for a document it could have | ||
* cached locally. |
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 think this statement is misleading as it gives indication that having documents in the cache will retrieve documents stored in the cached and go to the backend when not in cache.
Consider instead "This collector tries to ensure lowest memory footprints from the SDK, at the risk of documents not being cached for offline queries or for direct queries to the cache."
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.
Done.
|
||
createPersistence(cfg: ComponentConfiguration): Persistence { | ||
const lruParams = | ||
this.cacheSizeBytes !== undefined |
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.
wondering if we need a range check for this.cacheSizeBytes > 0
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.
This actually won't work because we use -1 to disable GC.
I really do not like this approach, we should do something similar to the new cache config API, using a dedicated enum branch to disable GC. Maybe something for the fixit week.
* (incoming GRPC messages), we should always schedule onto this queue. // | ||
* This ensures all of our work is properly serialized (e.g. we don't // | ||
* start processing a new operation while the previous one is waiting for // | ||
* an async I/O to complete). // |
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.
Not sure if ending //
were intentional
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.
Ah, I hate it when my editor does this and i don't know how to stop it.
persistence: MemoryPersistence, | ||
lruParams: LruParams | null | ||
): MemoryLruDelegate { | ||
return new MemoryLruDelegate(persistence, lruParams!!); |
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.
what is the double exclamation at the end of lruParams!!
do? I'm not familiar with the double.
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.
It tells complier that you are sure this is a LruParams
, not a null
. I removed | null
in this case, it was not neccessary.
withGCEnabled(gcEnabled: boolean): this { | ||
// Ensures manual LRU GC for both memory and indexeddb persistence. | ||
// In spec tests, GC is always manually triggered via triggerLruGC(). | ||
ensureManualLruGC(): this { | ||
debugAssert( | ||
!this.currentStep, | ||
'withGCEnabled() must be called before all spec steps.' |
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.
Update name in error message
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.
Done.
.triggerLruGC(1) | ||
.removeExpectedTargetMapping(query1) | ||
// should get no events. | ||
.userListens(query1) |
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.
Is the test name and the test implementation aligned on this one? Maybe I'm not following what it's trying to assert
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.
Nope, fixed.
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.
Thank you!
* | ||
* This collector tries to ensure lowest memory footprints from the SDK, | ||
* at the risk of querying backend repeated for a document it could have | ||
* cached locally. |
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.
Done.
|
||
createPersistence(cfg: ComponentConfiguration): Persistence { | ||
const lruParams = | ||
this.cacheSizeBytes !== undefined |
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.
This actually won't work because we use -1 to disable GC.
I really do not like this approach, we should do something similar to the new cache config API, using a dedicated enum branch to disable GC. Maybe something for the fixit week.
* (incoming GRPC messages), we should always schedule onto this queue. // | ||
* This ensures all of our work is properly serialized (e.g. we don't // | ||
* start processing a new operation while the previous one is waiting for // | ||
* an async I/O to complete). // |
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.
Ah, I hate it when my editor does this and i don't know how to stop it.
persistence: MemoryPersistence, | ||
lruParams: LruParams | null | ||
): MemoryLruDelegate { | ||
return new MemoryLruDelegate(persistence, lruParams!!); |
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.
It tells complier that you are sure this is a LruParams
, not a null
. I removed | null
in this case, it was not neccessary.
.triggerLruGC(1) | ||
.removeExpectedTargetMapping(query1) | ||
// should get no events. | ||
.userListens(query1) |
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.
Nope, fixed.
Please take a look, I need owner's approval for something outside of firestore. I do not understand why they show up though, they seem to be generated automatically. Check some changes under: common/ They are all auth-related. |
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.
- Sorry about auth.api.md. I made a PR to ensure it's reverted after docgen is run but this branch may have been created before that: Simplify check for reference doc changes #7014 You can just revert it.
- Can you add a changeset? It should be
@firebase/firestore
minor andfirebase
minor (theyarn changeset
CLI should help you add the first automatically, the second has to be added manually)
Done, thanks! |
.changeset/olive-cycles-count.md
Outdated
@@ -0,0 +1,6 @@ | |||
--- | |||
'firebase': patch |
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.
These should be minor as it's changing the API.
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.
Fixed, thanks.
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.
LG!
@@ -1241,6 +1257,6 @@ export function client( | |||
withGcEnabled?: boolean | |||
): MultiClientSpecBuilder { | |||
const specBuilder = new MultiClientSpecBuilder(); | |||
specBuilder.withGCEnabled(withGcEnabled === true); | |||
specBuilder.ensureManualLruGC(); |
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.
Shouldn't this be:
if (withGcEnabled !== true) {
specBuilder.ensureManualLruGC();
}
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.
Oh yeah, thanks for checking this.
I intended to delete withGcEnabled all together, because multitab will always have lru gc. I just forgot to delete it.
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.
see: #7234
Googlers see: go/firestore-memory-lru