Skip to content

[firebase-firestore] [BOM 34.8+] New ObjectValue equals method causes an exponential increase in execution time for large/deeply nested documents #7877

@davidpryor

Description

@davidpryor

[REQUIRED] Step 2: Describe your environment

  • Firebase Component: Firestore

Impacted BOMs: 34.8+

[REQUIRED] Step 3: Describe the problem

When the SDK is trying to calculate if a new snapshot needs to be restored, it calls view.computeDocChanges. This continues on to call boolean docsEqual = oldDoc.getData().equals(newDoc.getData());.

in commit b006a573f4404014cc5fef875ca9def84e9e0f99, the equality check for ObjectValue was changed from

-      return Values.equals(buildProto(), ((ObjectValue) o).buildProto());
+      return buildProto().equals(((ObjectValue) o).buildProto());

link to change

In previous commits, the Values.equals call returns immediately on large/deeply nested documents; running in milliseconds. In this commit and onward, this call is taking minutes.

We have experienced this both on a physical Samsung S20 Ultra and on an API 36 emulator.

Steps to reproduce:

Make a snapshot using a normal query (not a pipeline) of a large/deeply nested document. Write to this document to trigger a call for emitNewSnapsAndNotifyLocalStore. Observe the time it takes for ObjectValue.equals to complete from this call boolean docsEqual = oldDoc.getData().equals(newDoc.getData());

Relevant Code:

I am using the android SDK through the flutterfire cloud_firestore package, so I could use some guidance on the type of code you would need. I can provide a sample document if needed.

FlutterFire ticket: firebase/flutterfire#18089

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions