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

RUM-3574 perf: Start sending batches immediately after feature is initialized #1798

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- [IMPROVEMENT] Start sending data immediately after SDK is initialized. See [#1798][]

# 2.10.0 / 23-04-2024

- [IMPROVEMENT] Add image duplicate detection between sessions. See [#1747][]
Expand Down Expand Up @@ -639,6 +641,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1774]: https://github.com/DataDog/dd-sdk-ios/pull/1774
[#1763]: https://github.com/DataDog/dd-sdk-ios/pull/1763
[#1767]: https://github.com/DataDog/dd-sdk-ios/pull/1767
[#1798]: https://github.com/DataDog/dd-sdk-ios/pull/1798
[#1721]: https://github.com/DataDog/dd-sdk-ios/pull/1721
[#1747]: https://github.com/DataDog/dd-sdk-ios/pull/1747
[@00fa9a]: https://github.com/00FA9A
Expand Down
8 changes: 5 additions & 3 deletions DatadogCore/Sources/Core/Upload/DataUploadWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ internal class DataUploadWorker: DataUploadWorkerType {
self.maxBatchesPerUpload = maxBatchesPerUpload
self.featureName = featureName
self.telemetry = telemetry

self.readWork = DispatchWorkItem { [weak self] in
let readWorkItem = DispatchWorkItem { [weak self] in
guard let self = self else {
return
}
Expand All @@ -87,7 +86,10 @@ internal class DataUploadWorker: DataUploadWorkerType {
self.scheduleNextCycle()
}
}
scheduleNextCycle()
self.readWork = readWorkItem

// Start sending batches immediately after initialization:
queue.async(execute: readWorkItem)
}

private func scheduleNextCycle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,11 @@ class DataUploadWorkerTests: XCTestCase {
expectTaskEnded.fulfill()
}
)

// Given
writer.write(value: ["k1": "v1"])

// When
let worker = DataUploadWorker(
queue: uploaderQueue,
fileReader: reader,
Expand All @@ -620,7 +625,6 @@ class DataUploadWorkerTests: XCTestCase {
maxBatchesPerUpload: .mockRandom(min: 1, max: 100),
backgroundTaskCoordinator: backgroundTaskCoordinator
)
writer.write(value: ["k1": "v1"])

// Then
withExtendedLifetime(worker) {
Expand All @@ -638,6 +642,11 @@ class DataUploadWorkerTests: XCTestCase {
expectTaskEnded.fulfill()
}
)

// Given
writer.write(value: ["k1": "v1"])

// When
let worker = DataUploadWorker(
queue: uploaderQueue,
fileReader: reader,
Expand All @@ -650,7 +659,6 @@ class DataUploadWorkerTests: XCTestCase {
maxBatchesPerUpload: .mockRandom(min: 1, max: 100),
backgroundTaskCoordinator: backgroundTaskCoordinator
)
writer.write(value: ["k1": "v1"])

// Then
withExtendedLifetime(worker) {
Expand Down