Skip to content
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

Implement LRU Reference Delegate for Memory Persistence #1237

Merged
merged 9 commits into from
Sep 21, 2018

Conversation

gsoltis
Copy link

@gsoltis gsoltis commented Sep 19, 2018

This PR adds only the lru reference delegate for memory. The merge base is into lru-master.

Android Port: FirebasePrivate/firebase-android-sdk#190
iOS Port: firebase/firebase-ios-sdk#1600

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions/suggestions. Overall, this is a pretty close port to Android, which makes it easy to review. Thanks!


private _started = false;

private _referenceDelegate: ReferenceDelegate | null;
get referenceDelegate(): ReferenceDelegate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do keep this, please move it down past the constructor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, this will eventually just be a property. It's just waiting on the final reference delegate implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still like to push you to move this down to where we define other methods.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


private _started = false;

private _referenceDelegate: ReferenceDelegate | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been using just ReferenceDelegate as a the type if a member is essentially always set. Would it be possible to pass the delegate into the constructor from your factory function? You could then also make the variable itself public and remove the getter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I punt on this until the next PR? That one will introduce MemoryEagerDelegate, and then there will always be a reference delegate for memory persistence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a TODO to clean this up then :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

packages/firestore/src/local/memory_persistence.ts Outdated Show resolved Hide resolved
packages/firestore/src/local/memory_persistence.ts Outdated Show resolved Hide resolved
packages/firestore/src/local/memory_persistence.ts Outdated Show resolved Hide resolved
promises.push(referenceDelegate.addReference(txn, key));
});
}
return PersistencePromise.waitFor(promises);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the set of keys here is small, you could also do:

return PersistencePromise.forEach(keys.toArray(), key -> referenceDelegate.addReference(txn, key));

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's small? It's however many keys are added to a target.

packages/firestore/src/util/obj.ts Show resolved Hide resolved
@gsoltis gsoltis assigned schmidt-sebastian and unassigned gsoltis Sep 20, 2018
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM module a todo and moving the new getter method a little further down.

@gsoltis gsoltis merged commit 7f03511 into lru-master Sep 21, 2018
@gsoltis gsoltis deleted the gsoltis/memory_lru_delegate branch September 21, 2018 16:07
@gsoltis gsoltis mentioned this pull request Oct 4, 2018
gsoltis pushed a commit that referenced this pull request Oct 4, 2018
* 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
@firebase firebase locked and limited conversation to collaborators Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants