Skip to content

Conversation

@schmidt-sebastian
Copy link
Contributor

Reverts #4328

Reverting this change as it likely has performance implications (as shown in firebase/firebase-js-sdk#2487)

@schmidt-sebastian
Copy link
Contributor Author

This is a clean revert with no manual changes.

Copy link
Member

@ryanwilson ryanwilson left a comment

Choose a reason for hiding this comment

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

LGTM on Travis green, please add a changelog entry as well.

@ryanwilson
Copy link
Member

ryanwilson commented Jan 8, 2020

Changelog was updated in #4629

@schmidt-sebastian
Copy link
Contributor Author

cc @inlined

@schmidt-sebastian schmidt-sebastian merged commit 339c840 into master Jan 8, 2020
@paulb777 paulb777 added this to the M62 - 6.15.0 milestone Jan 8, 2020
lastWriteId = writeId;
self.writeIdCounter = writeId + 1;
id<FNode> existing =
[self.serverSyncTree calcCompleteEventCacheAtPath:write.path
Copy link
Member

Choose a reason for hiding this comment

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

@mikelehen Is this the same form that you recommended for web & saw in Android?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm... Actually, looking closer (sorry I haven't looked at all this code in 4+ years):

  1. This does look the same as Android.
  2. I think both Android and iOS are actually wrong / non-optimal, though not as bad as web was. We're still calculating existing at the root of the update instead of for the individual updated paths (but fortunately only once instead of repeatedly like web was).

I think maybe we could change resolveDeferredValueCompoundWrite to take the SyncTree and writePath (instead of existing) so that it can calculate exiting data only at the paths being updated. TBH this might end up being somewhat equivalent to your just-in-time SyncTree thing, though I'm not sure and I think it's better to avoid the additional indirection of that approach.

I think as-is this code is doing extra work and may behave incorrectly depending on what's in cache, since I think calcCompleteEventCache() will return an empty node if we don't have data cached for the location in question. So if you have data cached at /foo/bar but not /foo and you do fooRef.update({'bar': ServerValue.increment(1)}) then we'll end up calling calcEventCache() at /foo, getting an empty node, so even though later we will correctly do existing.child('bar'), it will still be empty and we'll apply the increment to an empty node instead of the value we have cached for /foo/bar.

Sorry I missed this when I looked at Android. This code was tricky to begin with and I haven't looked at it in too long.

@firebase firebase locked and limited conversation to collaborators Feb 8, 2020
@paulb777 paulb777 deleted the revert-4328-inlined.increments branch August 19, 2020 00:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants