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

Improvements during startup #101

Merged
merged 1 commit into from
Oct 25, 2024
Merged

Improvements during startup #101

merged 1 commit into from
Oct 25, 2024

Conversation

NachoEmbrace
Copy link
Contributor

@NachoEmbrace NachoEmbrace commented Oct 22, 2024

  • Improves Embrace.setup by 10ms-20ms

    • EmbraceConfig was unintentionally doing some stuff on the main thread. It is now being dispatched async on a different queue.
  • Improves Embrace.start by 10ms-20ms

    • I split CaptureServices.start into 2 methods. Only the install needed to be done on the main thread.
  • Fixes the remote config being fetched twice on startup.

@NachoEmbrace NachoEmbrace requested a review from a team as a code owner October 22, 2024 16:22
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

Warnings
⚠️ No CHANGELOG entry added.

Generated by 🚫 Danger Swift against 4c9d60c

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 85.24590% with 9 lines in your changes missing coverage. Please review.

Project coverage is 91.92%. Comparing base (996f59b) to head (4c9d60c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
Sources/EmbraceConfigInternal/EmbraceConfig.swift 73.33% 4 Missing ⚠️
Sources/EmbraceCore/Embrace.swift 25.00% 3 Missing ⚠️
Sources/EmbraceCore/Capture/CaptureServices.swift 60.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
- Coverage   91.95%   91.92%   -0.04%     
==========================================
  Files         408      408              
  Lines       26447    26438       -9     
==========================================
- Hits        24320    24303      -17     
- Misses       2127     2135       +8     
Files with missing lines Coverage Δ
...mbraceConfigInternalTests/EmbraceConfigTests.swift 100.00% <100.00%> (ø)
...ts/TestSupport/Mocks/MockEmbraceConfigurable.swift 74.57% <100.00%> (ø)
Sources/EmbraceCore/Capture/CaptureServices.swift 78.40% <60.00%> (-4.93%) ⬇️
Sources/EmbraceCore/Embrace.swift 70.70% <25.00%> (-10.47%) ⬇️
Sources/EmbraceConfigInternal/EmbraceConfig.swift 93.84% <73.33%> (+0.40%) ⬆️

... and 6 files with indirect coverage changes

)
}

self?.lastUpdateTime = Date().timeIntervalSince1970
Copy link
Contributor

Choose a reason for hiding this comment

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

If updateIfNeeded is called for the first time many times in quick succession its possible that we kick off multiple jobs onto this async queue.

Should we guard against this with the lastUpdateTime or should we introduce a variable to track that an update is currently in progress?

@@ -30,6 +32,7 @@ public class EmbraceConfig {
self.notificationCenter = notificationCenter
self.logger = logger
self.configurable = configurable
self.queue = DispatchQueue(label: "com.embrace.config", attributes: .concurrent)

update()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move this call to update as it is a side effect of the init method.

Think it makes more sense if we call this in the Embrace.start method in the async job here

@@ -92,11 +92,11 @@ public class MockEmbraceConfigurable: EmbraceConfigurable {
}
}

public let updateExpectation = XCTestExpectation(description: "update called")
public var updateCallCount = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why you moved away from the XCTestExpectation. Was this causing test failures?

@NachoEmbrace NachoEmbrace merged commit 61ac005 into main Oct 25, 2024
10 checks passed
@NachoEmbrace NachoEmbrace deleted the startup_improvements branch October 25, 2024 15:05
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