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

Firestore: Remove copies in FieldValueInternal to reduce global refs consumption. #1111

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

dconeybe
Copy link
Contributor

In field_value_android.h, change the std::vector<FieldValue> and MapFieldValue constructors to take const references, instead of values. This reduces by half the number of global references needed when DocumentReference::Set(), DocumentReference::Update(), and CollectionReference::Add() are called on Android.

Since these 3 methods are part of the public interface and take const references as their arguments, they are not able to std::move these values into the FieldValueInternal constructor, thus requiring copies. On Android, these copies necessitate doubling the number of JNI global references in use, making it much easier to hit the 51,200 hard limit.

This is the first part of a proper fix for the global refs exhaustion issue reported in firebase/quickstart-unity#1303 and firebase/quickstart-unity#1193 (comment) (Googlers see b/251869890 for more details). This should help alleviate the immediate problems being experienced by these customers. A proper fix is much more complicated and will take time to implement. Hopefully the improvement in this PR will be sufficient to unblock those customers.

…ue constructors to take const references, instead of values
@dconeybe dconeybe self-assigned this Oct 17, 2022
@dconeybe dconeybe added the tests-requested: quick Trigger a quick set of integration tests. label Oct 17, 2022
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. labels Oct 17, 2022
@github-actions
Copy link

github-actions bot commented Oct 17, 2022

❌  Integration test FAILED

Requested by @dconeybe on commit afa0cdd
Last updated: Mon Oct 17 14:36 PDT 2022
View integration test log & download artifacts

Failures Configs
gma [TEST] [FAILURE] [iOS] [macos] [1/2 ios_device: ios_target]
(1 failed tests)  FirebaseGmaTest.TestRewardedAdStress
storage [TEST] [ERROR] [iOS] [macos] [All 2 ios_device]
[TEST] [ERROR] [tvOS] [macos] [tvos_simulator]

Add flaky tests to go/fpl-cpp-flake-tracker

@github-actions github-actions bot added the tests: succeeded This PR's integration tests succeeded. label Oct 17, 2022
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Oct 17, 2022
Copy link
Contributor

@cherylEnkidu cherylEnkidu left a comment

Choose a reason for hiding this comment

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

Thank you!

@dconeybe dconeybe merged commit afa0cdd into main Oct 17, 2022
@dconeybe dconeybe deleted the dconeybe/ReduceAndroidFieldValueCopies branch October 17, 2022 18:25
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests: succeeded This PR's integration tests succeeded. labels Oct 17, 2022
@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Oct 17, 2022
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Oct 17, 2022
@firebase firebase locked and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: firestore tests: failed This PR's integration tests failed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants