Skip to content

Commit dd3ea8f

Browse files
author
Greg Soltis
authored
Merge LRU tracking PRs (#1285)
* Implement IndexedDB LRU Reference Delegate, add LRU tests (#1224) * Implement LRU Reference Delegate for Memory Persistence (#1237) * Implement Eager Reference Delegate for Memory Persistence, drop old GC (#1256) * Remove sequential forEach, replace with parallel forEach
1 parent 211a9b1 commit dd3ea8f

36 files changed

+2107
-930
lines changed

packages/firestore/src/core/firestore_client.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616

1717
import { CredentialsProvider } from '../api/credentials';
1818
import { User } from '../auth/user';
19-
import { EagerGarbageCollector } from '../local/eager_garbage_collector';
20-
import { GarbageCollector } from '../local/garbage_collector';
2119
import { IndexedDbPersistence } from '../local/indexeddb_persistence';
2220
import { LocalStore } from '../local/local_store';
2321
import { MemoryPersistence } from '../local/memory_persistence';
24-
import { NoOpGarbageCollector } from '../local/no_op_garbage_collector';
2522
import { Persistence } from '../local/persistence';
2623
import {
2724
DocumentKeySet,
@@ -83,7 +80,6 @@ export class FirestoreClient {
8380
// with the types rather than littering the code with '!' or unnecessary
8481
// undefined checks.
8582
private eventMgr: EventManager;
86-
private garbageCollector: GarbageCollector;
8783
private persistence: Persistence;
8884
private localStore: LocalStore;
8985
private remoteStore: RemoteStore;
@@ -292,7 +288,6 @@ export class FirestoreClient {
292288

293289
// TODO(http://b/33384523): For now we just disable garbage collection
294290
// when persistence is enabled.
295-
this.garbageCollector = new NoOpGarbageCollector();
296291
const storagePrefix = IndexedDbPersistence.buildStoragePrefix(
297292
this.databaseInfo
298293
);
@@ -347,8 +342,7 @@ export class FirestoreClient {
347342
* @returns A promise that will successfully resolve.
348343
*/
349344
private startMemoryPersistence(): Promise<void> {
350-
this.garbageCollector = new EagerGarbageCollector();
351-
this.persistence = new MemoryPersistence(this.clientId);
345+
this.persistence = MemoryPersistence.createEagerPersistence(this.clientId);
352346
this.sharedClientState = new MemorySharedClientState();
353347
return Promise.resolve();
354348
}
@@ -363,11 +357,7 @@ export class FirestoreClient {
363357
return this.platform
364358
.loadConnection(this.databaseInfo)
365359
.then(async connection => {
366-
this.localStore = new LocalStore(
367-
this.persistence,
368-
user,
369-
this.garbageCollector
370-
);
360+
this.localStore = new LocalStore(this.persistence, user);
371361
const serializer = this.platform.newSerializer(
372362
this.databaseInfo.databaseId
373363
);

packages/firestore/src/core/sync_engine.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
325325
this.remoteStore.unlisten(queryView.targetId);
326326
return this.removeAndCleanupQuery(queryView);
327327
})
328-
.then(() => this.localStore.collectGarbage())
329328
.catch(err => this.ignoreIfPrimaryLeaseLoss(err));
330329
}
331330
} else {
@@ -584,7 +583,6 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
584583
// NOTE: Both these methods are no-ops for batches that originated from
585584
// other clients.
586585
this.processUserCallback(batchId, error ? error : null);
587-
588586
this.localStore.removeCachedMutationBatchMetadata(batchId);
589587
} else {
590588
fail(`Unknown batchState: ${batchState}`);
@@ -821,12 +819,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
821819

822820
await Promise.all(queriesProcessed);
823821
this.syncEngineListener!.onWatchChange(newSnaps);
824-
this.localStore.notifyLocalViewChanges(docChangesInAllViews);
825-
if (this.isPrimary) {
826-
await this.localStore
827-
.collectGarbage()
828-
.catch(err => this.ignoreIfPrimaryLeaseLoss(err));
829-
}
822+
await this.localStore.notifyLocalViewChanges(docChangesInAllViews);
830823
}
831824

832825
/**

packages/firestore/src/local/eager_garbage_collector.ts

Lines changed: 0 additions & 103 deletions
This file was deleted.

packages/firestore/src/local/garbage_collector.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

packages/firestore/src/local/garbage_source.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)