Skip to content

Commit

Permalink
Smodi/compilation time tracking (#3685)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations. Feel free to change it, although assigning a GitHub
reviewer and the items in bold are required.

⚠️ If you're an external contributor, please file an issue first before
working on a PR, as we can't guarantee that we will accept your changes
if they haven't been discussed ahead of time. Thanks!
-->

Task/Issue URL:
https://app.asana.com/0/1208613456171888/1208801514911205/f
Tech Design URL:
https://app.asana.com/0/481882893211075/1208730499188670/f
CC:

**Description**:

<!--
If at any point it isn't actively being worked on/ready for
review/otherwise moving forward strongly consider closing it (or not
opening it in the first place). If you decide not to close it, use Draft
PR while work is still in progress or use `DO NOT MERGE` label to
clarify the PRs state and comment with more information.
-->

**Steps to test this PR**:
1.
2.

<!--
Before submitting a PR, please ensure you have tested the combinations
you expect the reviewer to test, then delete configurations you *know*
do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
-->

**Definition of Done (Internal Only)**:

* [ ] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

**Copy Testing**:

* [ ] Use of correct apostrophes in new copy, ie `’` rather than `'`

**Orientation Testing**:

* [ ] Portrait
* [ ] Landscape

**Device Testing**:

* [ ] iPhone SE (1st Gen)
* [ ] iPhone 8
* [ ] iPhone X
* [ ] iPhone 14 Pro
* [ ] iPad

**OS Testing**:

* [ ] iOS 15
* [ ] iOS 16
* [ ] iOS 17

**Theme Testing**:

* [ ] Light theme
* [ ] Dark theme

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)

---------

Co-authored-by: Bartek Waresiak <[email protected]>
  • Loading branch information
studiosutara and bwaresiak authored Dec 9, 2024
1 parent 7ae0fc2 commit 8c0cb45
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Core/ContentBlocking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ public final class ContentBlocking {

domainEvent = .contentBlockingCompilationFailed(listType: listType, component: component)

case .contentBlockingCompilationTime:
domainEvent = .contentBlockingCompilationTime

case .contentBlockingLookupRulesSucceeded:
domainEvent = .contentBlockingLookupRulesSucceeded

Expand All @@ -130,6 +127,10 @@ public final class ContentBlocking {

case .contentBlockingLRCMissing:
domainEvent = .contentBlockingLRCMissing

case .contentBlockingCompilationTaskPerformance(let retryCount, let timeBucketAggregation):
domainEvent = .contentBlockingCompilationTaskPerformance(iterationCount: retryCount,
timeBucketAggregation: Pixel.Event.CompileTimeBucketAggregation(number: timeBucketAggregation))
}

if let error = error {
Expand Down
51 changes: 48 additions & 3 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,12 @@ extension Pixel {
case contentBlockingCompilationFailed(listType: CompileRulesListType,
component: ContentBlockerDebugEvents.Component)

case contentBlockingCompilationTime
case contentBlockingLookupRulesSucceeded
case contentBlockingFetchLRCSucceeded
case contentBlockingNoMatchInLRC
case contentBlockingLRCMissing

case contentBlockingCompilationTaskPerformance(iterationCount: Int, timeBucketAggregation: CompileTimeBucketAggregation)
case ampBlockingRulesCompilationFailed

case webKitDidTerminate
Expand Down Expand Up @@ -1408,13 +1408,14 @@ extension Pixel.Event {
case .contentBlockingCompilationFailed(let listType, let component):
return "m_d_content_blocking_\(listType)_\(component)_compilation_failed"

case .contentBlockingCompilationTime: return "m_content_blocking_compilation_time"

case .contentBlockingLookupRulesSucceeded: return "m_content_blocking_lookup_rules_succeeded"
case .contentBlockingFetchLRCSucceeded: return "m_content_blocking_fetch_lrc_succeeded"
case .contentBlockingNoMatchInLRC: return "m_content_blocking_no_match_in_lrc"
case .contentBlockingLRCMissing: return "m_content_blocking_lrc_missing"

case .contentBlockingCompilationTaskPerformance(let iterationCount, let timeBucketAggregation):
return "m_content_blocking_compilation_loops_\(iterationCount)_time_\(timeBucketAggregation)"
case .ampBlockingRulesCompilationFailed: return "m_debug_amp_rules_compilation_failed"

case .webKitDidTerminate: return "m_d_wkt"
Expand Down Expand Up @@ -1880,6 +1881,50 @@ extension Pixel.Event {
case blockingAttribution
case attributed
case unknown


}

public enum CompileTimeBucketAggregation: String, CustomStringConvertible {

public var description: String { rawValue }

case lessThan1 = "1"
case lessThan2 = "2"
case lessThan3 = "3"
case lessThan4 = "4"
case lessThan5 = "5"
case lessThan6 = "6"
case lessThan7 = "7"
case lessThan8 = "8"
case lessThan9 = "9"
case lessThan10 = "10"
case more

public init(number: Double) {
switch number {
case ...1:
self = .lessThan1
case ...2:
self = .lessThan2
case ...3:
self = .lessThan3
case ...4:
self = .lessThan4
case ...5:
self = .lessThan5
case ...6:
self = .lessThan6
case ...7:
self = .lessThan7
case ...8:
self = .lessThan8
case ...9:
self = .lessThan9
case ...10:
self = .lessThan10
default:
self = .more
}
}
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11570,7 +11570,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 219.1.0;
version = 220.0.0;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "6c335fb4355e7128dd9fb9fd25ac3de8942846ad",
"version" : "219.1.0"
"revision" : "55e7de13a99793329993367169c9b6bafbd07bac",
"version" : "220.0.0"
}
},
{
Expand Down

0 comments on commit 8c0cb45

Please sign in to comment.