Skip to content

LOOP-1169 - Upload device logs#100

Merged
ps2 merged 3 commits into
devfrom
ps2/LOOP-1169/upload-device-logs
Jun 10, 2024
Merged

LOOP-1169 - Upload device logs#100
ps2 merged 3 commits into
devfrom
ps2/LOOP-1169/upload-device-logs

Conversation

@ps2

@ps2 ps2 commented Jun 4, 2024

Copy link
Copy Markdown
Contributor

@ps2 ps2 requested review from Camji55 and nhamming June 4, 2024 01:52
Comment on lines +87 to +88
await tapi.setLogging(self)
await tapi.addObserver(self)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do these need to run sequentially or in this particular order? If not, we could run them simultaneously to get a tad bit more performance with a TaskGroup.

Suggested change
await tapi.setLogging(self)
await tapi.addObserver(self)
await withTaskGroup { group in
group.addTask { await tapi.setLogging(self) }
group.addTask { await tapi.addObserver(self) }
await group.waitForAll()
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd be very surprised if this created any measurable performance improvement. Combining that with the additional code and complexity and loss of readability, I don't think it would be worth it, especially for a situation where performance isn't important in the first place.

Comment on lines +344 to +345
let _ = try await createData(created.flatMap { $0.data(for: userId, hostIdentifier: hostIdentifier, hostVersion: hostVersion) })
let _ = try await deleteData(withSelectors: deleted.flatMap { $0.selectors })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to above. Another possible use of TaskGroup?

Suggested change
let _ = try await createData(created.flatMap { $0.data(for: userId, hostIdentifier: hostIdentifier, hostVersion: hostVersion) })
let _ = try await deleteData(withSelectors: deleted.flatMap { $0.selectors })
await withThrowingTaskGroup(of: Void.self) { group in
group.addTask { try await createData(created.flatMap { $0.data(for: userId, hostIdentifier: hostIdentifier, hostVersion: hostVersion) }) }
group.addTask { try await deleteData(withSelectors: deleted.flatMap { $0.selectors }) }
await group.waitForAll()
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Serialization is needed here; some of the deletes may be for objects created in the createData line.

Comment on lines +433 to +434
let _ = try await createData(created)
let _ = try await updateData(updated)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to above. Another possible use of TaskGroup?

Suggested change
let _ = try await createData(created)
let _ = try await updateData(updated)
await withThrowingTaskGroup(of: Void.self) { group in
group.addTask { try await createData(created) }
group.addTask { try await updateData(updated) }
await group.waitForAll()
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Serialization is intended here.

do {
// TODO: fetching logs is not implemented on the backend yet: awaiting https://tidepool.atlassian.net/browse/BACK-3011
// For now, we expect this to error, so the catch has been modified to break out of the loop. Once this is implemented,
// We will want to retry on error, so the break should eventually be removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this mean that the upload will potentially upload redundant data each time Tidepool Loop is restarted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I noted this in the ticket.

@ps2 ps2 merged commit a723ade into dev Jun 10, 2024
@ps2 ps2 deleted the ps2/LOOP-1169/upload-device-logs branch June 10, 2024 15:16
loopkitdev pushed a commit to loopkitdev/TidepoolService that referenced this pull request Mar 12, 2026
* Update for remote data service protocol changes

* Upload device logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants