Skip to content

Expose operation counts from Persistence layer #2164

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

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Sep 9, 2019

This is a port of firebase/firebase-android-sdk#595

The ultimate goal of this PR is to allow us write unit tests that count how many items are processed during query execution. For this to work, this PR adds a StatsCollector. The RemoteDocumentCache and the MutationQueue have been updated to provide stats for every read, delete and insert operation. I tried to ensure that they counts between the different backing stores would match and added a unit test that ensures that this is true for a small subset of the operations.

I also changed the way that MemoryPersistence gets initialized to align it a bit closer with IndexedDbPersistence.

There are likely a bunch of issues with the stats accounting that we could either:

  • Ignore.
  • Uncover by adding more unit test.
  • Address by removing the stats accounting for areas of this PR that are not tested.

We could also drop this PR altogether and only do the counting on one platform.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

This looks like a reasonable port. But you seem ambivalent about if/how we should move forward with this. :-)

I don't have super strong feelings, but:

  1. I'm not wild about testing how code works (internal state) instead of just whether it works. It's easy for such tests to be fragile and break whenever the code changes, even if the code is still correct and working as intended.
  2. I would prefer if we could measure the benefit of index-free queries (and guard against regressions) via real perf tests, but we don't really have infrastructure for that. So maybe this is a reasonable alternative.
  3. I don't love having to pass statsCollectors into all of our persistence components... It's a little tempting to hang it off of the transaction or something.
  4. If we're looking for a reason not to move forward with this, I notice that it adds 2471 bytes to the SDK (533 after gzip) for test-only code.

Thoughts on how to proceed? If you want to check it in as-is, I'm fine with that. If we want to drop the PR, I'm probably fine with that too. But we should probably add a PORTING NOTE to Android or something to make it clear this is intentional.

@schmidt-sebastian
Copy link
Contributor Author

Dropping in favor of more isolated approach in #2165

@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/indexfree-counter branch September 10, 2019 21:52
@firebase firebase locked and limited conversation to collaborators Oct 11, 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.

2 participants