Skip to content

Share settings cache between running processes #6788

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

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

mrober
Copy link
Contributor

@mrober mrober commented Mar 20, 2025

With the multi-process data store change, all processes will read the settings cache from the same file safely. This means if a second process started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new settings, it wouldn't automatically share it with the other running process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid converting units. Cleaned up unit tests. Also removed the need to lazy load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.

@google-oss-bot
Copy link
Contributor

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

@mrober mrober requested review from tejasd and themiswang March 20, 2025 17:52
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 20, 2025

Coverage Report 1

Affected Products

  • firebase-sessions

    Overall coverage changed from ? (62508f2) to 68.60% (ba97c68) by ?.

    46 individual files with coverage change

    FilenameBase (62508f2)Merge (ba97c68)Diff
    ApplicationInfo.kt?100.00%?
    AutoSessionEventEncoder.java?100.00%?
    Comparisons.kt?100.00%?
    DaggerFirebaseSessionsComponent.java?0.00%?
    EventGDTLogger.kt?70.00%?
    EventGDTLogger_Factory.java?0.00%?
    FirebaseSessions.kt?0.00%?
    FirebaseSessionsComponent.kt?0.00%?
    FirebaseSessionsComponent_MainModule_Companion_ApplicationInfoFactory.java?0.00%?
    FirebaseSessionsComponent_MainModule_Companion_SessionConfigsDataStoreFactory.java?0.00%?
    FirebaseSessionsComponent_MainModule_Companion_SessionDataStoreFactory.java?0.00%?
    FirebaseSessionsComponent_MainModule_Companion_TimeProviderFactory.java?0.00%?
    FirebaseSessionsComponent_MainModule_Companion_UuidGeneratorFactory.java?0.00%?
    FirebaseSessionsDependencies.kt?92.00%?
    FirebaseSessionsRegistrar.kt?0.00%?
    FirebaseSessions_Factory.java?0.00%?
    InstallationId.kt?100.00%?
    LocalOverrideSettings.kt?100.00%?
    LocalOverrideSettings_Factory.java?0.00%?
    ProcessDetailsProvider.kt?76.67%?
    RemoteSettings.kt?88.41%?
    RemoteSettingsFetcher.kt?0.00%?
    RemoteSettingsFetcher_Factory.java?0.00%?
    RemoteSettings_Factory.java?0.00%?
    SessionConfigs.kt?95.45%?
    SessionDatastore.kt?78.13%?
    SessionDatastoreImpl_Factory.java?0.00%?
    SessionEvent.kt?100.00%?
    SessionEvents.kt?98.00%?
    SessionFirelogPublisher.kt?84.21%?
    SessionFirelogPublisherImpl_Factory.java?0.00%?
    SessionGenerator.kt?95.45%?
    SessionGenerator_Factory.java?0.00%?
    SessionLifecycleClient.kt?91.78%?
    SessionLifecycleService.kt?78.41%?
    SessionLifecycleServiceBinder.kt?0.00%?
    SessionLifecycleServiceBinderImpl_Factory.java?0.00%?
    SessionsActivityLifecycleCallbacks.kt?55.56%?
    SessionsSettings.kt?96.88%?
    SessionsSettings_Factory.java?0.00%?
    SessionSubscriber.kt?100.00%?
    SettingsCache.kt?80.56%?
    SettingsCacheImpl_Factory.java?0.00%?
    SettingsProvider.kt?50.00%?
    TimeProvider.kt?60.00%?
    UuidGenerator.kt?100.00%?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/JPIn8PCRX1.html

Copy link
Contributor

github-actions bot commented Mar 20, 2025

Test Results

  146 files    146 suites   2m 40s ⏱️
1 054 tests 1 054 ✅ 0 💤 0 ❌
2 108 runs  2 108 ✅ 0 💤 0 ❌

Results for commit 306bdc6.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 20, 2025

Size Report 1

Affected Products

  • base

    TypeBase (62508f2)Merge (ba97c68)Diff
    apk (aggressive)?8.80 kB? (?)
    apk (release)?9.77 kB? (?)
  • firebase-sessions

    TypeBase (62508f2)Merge (ba97c68)Diff
    aar?207 kB? (?)
    apk (aggressive)?420 kB? (?)
    apk (release)?5.78 MB? (?)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/hsGDOYgiY3.html

Copy link
Contributor

@tejasd tejasd left a comment

Choose a reason for hiding this comment

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

This change itself LGTM.

However, based on our discussion - removing SessionLifecycleService seems like a non trivial change - and I would defer that to someone with more context.

@mrober mrober merged commit 0115417 into fireperf-aqs Mar 24, 2025
35 checks passed
@mrober mrober deleted the mrober/cachesettings branch March 24, 2025 13:11
mrober added a commit that referenced this pull request Mar 27, 2025
With the multi-process data store change, all processes will read the
settings cache from the same file safely. This means if a second process
started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new
settings, it wouldn't automatically share it with the other running
process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid
converting units. Cleaned up unit tests. Also removed the need to lazy
load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.
themiswang pushed a commit that referenced this pull request Mar 31, 2025
With the multi-process data store change, all processes will read the
settings cache from the same file safely. This means if a second process
started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new
settings, it wouldn't automatically share it with the other running
process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid
converting units. Cleaned up unit tests. Also removed the need to lazy
load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.
tejasd pushed a commit that referenced this pull request Apr 1, 2025
With the multi-process data store change, all processes will read the
settings cache from the same file safely. This means if a second process
started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new
settings, it wouldn't automatically share it with the other running
process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid
converting units. Cleaned up unit tests. Also removed the need to lazy
load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.
mrober added a commit that referenced this pull request Apr 7, 2025
With the multi-process data store change, all processes will read the
settings cache from the same file safely. This means if a second process
started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new
settings, it wouldn't automatically share it with the other running
process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid
converting units. Cleaned up unit tests. Also removed the need to lazy
load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.
mrober added a commit that referenced this pull request Apr 15, 2025
With the multi-process data store change, all processes will read the
settings cache from the same file safely. This means if a second process
started, it would read the cache the first process persisted.

But if 2 processes were already running, and one fetched and cached new
settings, it wouldn't automatically share it with the other running
process.

This change fixes that by having all processes watch the file.

Also cleaned up settings a bit, and made everything in seconds to avoid
converting units. Cleaned up unit tests. Also removed the need to lazy
load the cache by doing a double check in the getter instead.

There is more potential to clean up, but let's do it later.
@firebase firebase locked and limited conversation to collaborators Apr 24, 2025
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.

4 participants