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

Make disabling GC prevent even scheduling it #2862

Merged
merged 4 commits into from Apr 19, 2019
Merged

Conversation

wilhuff
Copy link
Contributor

@wilhuff wilhuff commented Apr 18, 2019

We learned in #2846 that the current implementation isn't an effective way to disable GC, because the empty commit itself was failing.

Also make the linkage of kFIRFirestoreCacheSizeUnlimited explicitly extern "C". This previously had no fixed linkage in the header and only accidentally worked because the implementation had C++ linkage.

Move internal CacheSizeUnlimited to api::Settings and the definition of kFIRFirestoreCacheSizeUnlimited into the Objective-C language binding.

Move the rest of the FIRFirestoreSettings defaults to api::Settings as well.

Also make the linkage of kFIRFirestoreCacheSizeUnlimited explicitly
extern "C". This previously had no fixed linkage in the header and must
have accidentally worked because the implementation had C++ linkage.

Finally, move internal CacheSizeUnlimited to api::Settings and the
definition of kFIRFirestoreCacheSizeUnlimited into the Objective-C
language binding.
@@ -35,6 +35,9 @@
static const int64_t kMinimumCacheSizeBytes = 1 * 1024 * 1024;
static const BOOL kDefaultTimestampsInSnapshotsEnabled = YES;

// Public constant
extern "C" const int64_t kFIRFirestoreCacheSizeUnlimited = api::Settings::CacheSizeUnlimited;
Copy link
Contributor

Choose a reason for hiding this comment

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

When I did the api::Settings port I was thinking about moving all the defaults to be defined there but wasn't sure if that would open the door for static initialization order fiasco, so I left it as-is. But I guess this is safe because it's a builtin value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key to making that work is to ensure that the values are compiler initialized. Making values constexpr is one guaranteed way to do that. Another is to annotate the value with ABSL_CONST_INIT which adds an attribute that would cause a compiler error if the value could not be compiler initialized.

With that in place it's safe to refer to other values in the definition of a constant. I've ported all the settings defaults as well.

@mikelehen mikelehen assigned wilhuff and unassigned mikelehen Apr 18, 2019
Ensure that all defaults are compiler initialized to ensure there are no
initialization order problems.
@wilhuff wilhuff assigned mikelehen and unassigned wilhuff Apr 18, 2019
@wilhuff
Copy link
Contributor Author

wilhuff commented Apr 18, 2019

PTAL

@mikelehen
Copy link
Contributor

It looks like some hexa-reworking ended up in this PR. I'm happy to review together, but checking if that was intentional?

@wilhuff
Copy link
Contributor Author

wilhuff commented Apr 18, 2019

Whoops, not intentional. I'll remove it.

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.

LGTM. Thanks for reworking the settings defaults!

@mikelehen mikelehen assigned wilhuff and unassigned mikelehen Apr 18, 2019
@wilhuff wilhuff merged commit 9a3ba6e into master Apr 19, 2019
@wilhuff wilhuff deleted the wilhuff/gc-disabled branch April 19, 2019 01:17
Corrob pushed a commit that referenced this pull request Apr 25, 2019
* Make disabling GC prevent even scheduling it

Make the linkage of kFIRFirestoreCacheSizeUnlimited explicitly
extern "C". This previously had no fixed linkage in the header and must
have accidentally worked because the implementation had C++ linkage.

Move internal CacheSizeUnlimited to api::Settings and the
definition of kFIRFirestoreCacheSizeUnlimited into the Objective-C
language binding.

Migrate settings defaults to C++ settings

Ensure that all defaults are compiler initialized to ensure there are no
initialization order problems.
@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.

None yet

3 participants