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

chore: log sync phases in legacy code and new code - WPB-15289 #2373

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

jullianm
Copy link
Contributor

@jullianm jullianm commented Jan 9, 2025

TaskWPB-15289 Report slow sync time

Issue

This PR adds logs for the duration of a sync phase as well as the full duration of a sync to complete (quick or slow sync).
Added to both legacy code and new code in WireDomain.

It will help us analyze and compare the duration between the old sync mechanism and the new one on Datadog.

Testing

N/A

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.

Logs would look as follows:

Screenshot 2025-01-10 at 14 43 57

@echoes-hq echoes-hq bot added echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt. echoes/initiative: ios-sync-refactoring labels Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

Test Results

2 723 tests   2 721 ✅  4m 11s ⏱️
    4 suites      2 💤
    4 files        0 ❌

Results for commit 9b0d2d1.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Jan 9, 2025

Datadog Report

Branch report: chore/add-time-spent-logs-quick-slow-sync
Commit report: 80ddbbb
Test service: wire-ios-mono

✅ 0 Failed, 2589 Passed, 2 Skipped, 2m 45.87s Total Time

Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

logic looks good, but data must be in attributes in order to use it in datadog, see comments

Comment on lines 304 to 305
let message = "Completed \(syncType) phase \(phase) in \(duration)"
WireLogger.sync.info(message, attributes: .safePublic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let message = "Completed \(syncType) phase \(phase) in \(duration)"
WireLogger.sync.info(message, attributes: .safePublic)
let message = "SyncPhase completed"
WireLogger.sync.info(message, attributes: [.duration: \(duration), .syncType: syncType, .phase: phase], .safePublic)

better to move the info inside attributes so in datadog we can extract it directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in aaa6638

Comment on lines 311 to 312
let message = "Completed \(syncType) in \(syncTimeTracker.totalSyncDuration())"
WireLogger.sync.info(message, attributes: .safePublic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let message = "Completed \(syncType) in \(syncTimeTracker.totalSyncDuration())"
WireLogger.sync.info(message, attributes: .safePublic)
let message = "Completed \(syncType)"
WireLogger.sync.info(message, attributes: [.sync_duration: syncTimeTracker.totalSyncDuration(), .syncType: syncType], .safePublic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in aaa6638

Comment on lines 42 to 43
let syncType = isSlowSyncing ? "slow sync" : "quick sync"
WireLogger.sync.info("Started \(syncType) phase \(currentSyncPhase)", attributes: .safePublic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe add an attribute syncSystem: "legacy" or syncSystem: "new" to distinguish which system is running. it should contain same attributes as in new system

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in aaa6638

wire-ios-sync-engine/Source/UserSession/SyncStatus.swift Outdated Show resolved Hide resolved
wire-ios-sync-engine/Source/UserSession/SyncStatus.swift Outdated Show resolved Hide resolved
wire-ios-sync-engine/Source/UserSession/SyncStatus.swift Outdated Show resolved Hide resolved
@samwyndham
Copy link
Contributor

Un-assigning myself as this PR already has a couple of active reviewers. @jullianm Feel free to add me back if you would like.

@samwyndham samwyndham removed their request for review January 10, 2025 08:56
@jullianm jullianm requested a review from netbe January 10, 2025 11:09
@jullianm
Copy link
Contributor Author

I've noticed a funny duration number for the first slow sync phase in legacy code. Probably the time we trigger the timer for this first event should be set later on. I suspect the time we determine the initial sync phase is not the time we actually start to perform the fetch.
I will investigate on that. @netbe

@jullianm
Copy link
Contributor Author

So, the weird duration value for the first slow sync phase would only occur when we run into the case where we have too many devices: we determine the first slow sync phase and start the slow sync but the app is kind of in an idle state where the first phase is not being actually executed until we removed a device (issue was that the timer would've already started).

Solution is to start the timer only when the first slow sync phase is actually executed, commit b54bbc1

@netbe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes/initiative: ios-sync-refactoring echoes: technical-roadmap Work contributing to the Technical Roadmap, to improve our velocity or reduce the technical debt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants