-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor(sync): enable concurrent sync start/stop [WPB-15262] #3304
base: develop
Are you sure you want to change the base?
refactor(sync): enable concurrent sync start/stop [WPB-15262] #3304
Conversation
Removes the concept of ConnectionPolicy, replacing it with `SyncExecutor` operations. Multiple entities can easily call `syncExecutor.request {}`, which is far easier than having to manage the ConnectionPolicy flags.
4cb134a
to
158aa01
Compare
Test Results3 524 tests +4 3 416 ✅ +4 6m 11s ⏱️ -18s Results for commit 5502dae. ± Comparison against base commit 7c462ea. This pull request removes 40 and adds 44 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
|
Branch | refactor/sync/allow-concurrent-sync-start-stopping |
Testbed | ubuntu-latest |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholds
flag.
Click to view all benchmark results
Benchmark | Latency | microseconds (µs) |
---|---|---|
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles | 📈 view plot | 762.20 |
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory | 📈 view plot | 408,452.04 |
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark | 📈 view plot | 1,416,548.46 |
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark | 📈 view plot | 28,176.11 |
Datadog ReportBranch report: ✅ 0 Failed, 3416 Passed, 108 Skipped, 1m 2.01s Total Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 🚀 just one comment
override val syncState: StateFlow<SyncState> get() = mutableSyncState.asStateFlow() | ||
|
||
override suspend fun waitUntilLive() { | ||
TODO("Not yet implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those mocks will throw exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions aren't used anywhere. The only place using this Fake is in SyncExecutorTest
. And SyncExecutor
only needs the syncState
.
So it's fine to leave them like this.
If someone wants to use this Fake elsewhere, feel free to fill the gaps 😄
Refactored the sync component to introduce a `SyncRequest` interface, enabling better testing. This change simplifies the logic, enhances maintainability, and clarifies responsibilities across sync-related classes. Additionally, exception handling was standardized across sync managers.
Properly start sync in tango test
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3304 +/- ##
===========================================
+ Coverage 50.68% 50.70% +0.01%
===========================================
Files 1611 1610 -1
Lines 58145 58188 +43
Branches 5246 5249 +3
===========================================
+ Hits 29473 29503 +30
- Misses 26645 26657 +12
- Partials 2027 2028 +1 see 19 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
It is a pain to start/stop sync from multiple places using
ConnectionPolicy
.For instance, what if you want to start sync, perform an operation, and then stop?
You'd need to set the policy, wait, and then reset it to whatever value it was. But what about race conditions? What if another piece of code is changing that too?
PAIN
Solutions
Rename
SyncManager
SyncManager
is nowSyncStateObserver
. It had the name of "Manager" but it didn't manage anything. It still has the same function: observe state and passively wait for specific states.Move Sync start/stop logic to
SyncExecutor
Instead of having only autonomous
SlowSyncManager
andIncrementalSyncManager
that would start/stop on their own and follow the policy: NowSyncExecutor
will allow multiple requests to be made at the same time. If at least one request is alive, it will start Sync.Multiple entities can easily call
syncExecutor.request {}
.Some examples:
Although not visible in this PR, the code in wire-android regarding sync policy will be reduced and simplified A LOT.
Note
Maybe
SyncStateObserver
andSyncExecutor
could be the same class and be namedSyncManager
. HOWEVER, I've identified a few cyclic dependencies during this process. Some classes that are used during event processing have dependencies onSyncManager
. It is possible to go around it, but in the end I opted to have these two entities: one responsible for passively watching Sync. Another responsible for actively requesting it.Testing
Test Coverage
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.