Skip to content

Commit 33cbda0

Browse files
committed
[CAS] Change the detailed caching diagnostic remarks to be notes instead
Remarks pollute the issue navigator in Xcode, the notes are more appropriate as offering additional details for a particular task.
1 parent 3be4320 commit 33cbda0

10 files changed

+43
-35
lines changed

Sources/SWBTaskExecution/DynamicTaskSpecs/CompilationCachingDataPruner.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ package final class CompilationCachingDataPruner: Sendable {
114114
do {
115115
let dbSize = try casDBs.getOndiskSize()
116116
let sizeLimit = try computeCASSizeLimit(casOptions: casOpts, dbSize: dbSize, fileSystem: fs)
117-
if casOpts.enableDiagnosticRemarks, let dbSize, let sizeLimit, sizeLimit < dbSize {
117+
if let dbSize, let sizeLimit, sizeLimit < dbSize {
118118
activityReporter.emit(
119119
diagnostic: Diagnostic(
120-
behavior: .remark,
120+
behavior: .note,
121121
location: .unknown,
122122
data: DiagnosticData("cache size (\(dbSize)) larger than size limit (\(sizeLimit))")
123123
),
@@ -183,10 +183,10 @@ package final class CompilationCachingDataPruner: Sendable {
183183
do {
184184
let dbSize = try casDBs.getStorageSize()
185185
let sizeLimit = try computeCASSizeLimit(casOptions: casOpts, dbSize: dbSize.map{Int($0)}, fileSystem: fs)
186-
if casOpts.enableDiagnosticRemarks, let dbSize, let sizeLimit, sizeLimit < dbSize {
186+
if let dbSize, let sizeLimit, sizeLimit < dbSize {
187187
activityReporter.emit(
188188
diagnostic: Diagnostic(
189-
behavior: .remark,
189+
behavior: .note,
190190
location: .unknown,
191191
data: DiagnosticData("cache size (\(dbSize)) larger than size limit (\(sizeLimit))")
192192
),
@@ -252,10 +252,10 @@ package final class CompilationCachingDataPruner: Sendable {
252252
do {
253253
let dbSize = (try? toolchainCAS.getOnDiskSize()).map { Int($0) }
254254
let sizeLimit = try computeCASSizeLimit(casOptions: casOpts, dbSize: dbSize, fileSystem: fs).map { Int64($0) }
255-
if casOpts.enableDiagnosticRemarks, let dbSize, let sizeLimit, sizeLimit < dbSize {
255+
if let dbSize, let sizeLimit, sizeLimit < dbSize {
256256
activityReporter.emit(
257257
diagnostic: Diagnostic(
258-
behavior: .remark,
258+
behavior: .note,
259259
location: .unknown,
260260
data: DiagnosticData("cache size (\(dbSize)) larger than size limit (\(sizeLimit))")
261261
),

Sources/SWBTaskExecution/DynamicTaskSpecs/CompilationCachingUploader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ package final class CompilationCachingUploader {
8282
if enableDiagnosticRemarks {
8383
for output in clangCompilation.getOutputs() {
8484
activityReporter.emit(
85-
diagnostic: Diagnostic(behavior: .remark, location: .unknown, data: DiagnosticData("uploaded CAS output \(output.name): \(output.casID)")),
85+
diagnostic: Diagnostic(behavior: .note, location: .unknown, data: DiagnosticData("uploaded CAS output \(output.name): \(output.casID)")),
8686
for: activityID,
8787
signature: signature
8888
)
@@ -144,7 +144,7 @@ package final class CompilationCachingUploader {
144144
if enableDiagnosticRemarks {
145145
for output in try swiftCompilation.getOutputs() {
146146
activityReporter.emit(
147-
diagnostic: Diagnostic(behavior: .remark,
147+
diagnostic: Diagnostic(behavior: .note,
148148
location: .unknown,
149149
data: DiagnosticData("uploaded CAS output \(output.kindName): \(output.casID)")),
150150
for: activityID,

Sources/SWBTaskExecution/TaskActions/ClangCachingKeyQueryTaskAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public final class ClangCachingKeyQueryTaskAction: TaskAction {
6464
cachedComp = nil
6565
}
6666
if key.casOptions.enableDiagnosticRemarks {
67-
outputDelegate.remark("cache \(cachedComp != nil ? "hit" : "miss")")
67+
outputDelegate.note("cache \(cachedComp != nil ? "hit" : "miss")")
6868
}
6969
return .succeeded
7070
} catch {

Sources/SWBTaskExecution/TaskActions/ClangCachingOutputMaterializerTaskAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public final class ClangCachingOutputMaterializerTaskAction: TaskAction {
5959
}
6060
if obj == nil {
6161
if key.casOptions.enableDiagnosticRemarks {
62-
outputDelegate.remark("missing CAS object: \(key.casID)")
62+
outputDelegate.note("missing CAS object: \(key.casID)")
6363
}
6464
}
6565
return .succeeded

Sources/SWBTaskExecution/TaskActions/ClangCompileTaskAction.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public final class ClangCompileTaskAction: TaskAction, BuildValueValidatingTaskA
369369
}
370370
guard let cachedComp = try casDBs.getLocalCachedCompilation(cacheKey: cacheKey) else {
371371
if enableDiagnosticRemarks {
372-
outputDelegate.remark("cache miss: \(cacheKey)")
372+
outputDelegate.note("cache miss: \(cacheKey)")
373373
}
374374
outputDelegate.incrementClangCacheMiss()
375375
outputDelegate.incrementTaskCounter(.cacheMisses)
@@ -380,8 +380,8 @@ public final class ClangCompileTaskAction: TaskAction, BuildValueValidatingTaskA
380380
for output in outputs {
381381
guard cachedComp.isOutputMaterialized(output) else {
382382
if enableDiagnosticRemarks {
383-
outputDelegate.remark("missing CAS output \(output.name): \(output.casID)")
384-
outputDelegate.remark("cache miss: \(cacheKey)")
383+
outputDelegate.note("missing CAS output \(output.name): \(output.casID)")
384+
outputDelegate.note("cache miss: \(cacheKey)")
385385
}
386386
outputDelegate.incrementClangCacheMiss()
387387
outputDelegate.incrementTaskCounter(.cacheMisses)
@@ -390,9 +390,9 @@ public final class ClangCompileTaskAction: TaskAction, BuildValueValidatingTaskA
390390
}
391391
let diagnosticText = try cachedComp.replay(commandLine: command.arguments, workingDirectory: workingDirectory.str)
392392
if enableDiagnosticRemarks {
393-
outputDelegate.remark("replayed cache hit: \(cacheKey)")
393+
outputDelegate.note("replayed cache hit: \(cacheKey)")
394394
for output in outputs {
395-
outputDelegate.remark("using CAS output \(output.name): \(output.casID)")
395+
outputDelegate.note("using CAS output \(output.name): \(output.casID)")
396396
}
397397
}
398398
outputDelegate.incrementClangCacheHit()
@@ -415,7 +415,7 @@ public final class ClangCompileTaskAction: TaskAction, BuildValueValidatingTaskA
415415
guard let cachedComp = try casDBs.getLocalCachedCompilation(cacheKey: cacheKey) else {
416416
// This can happen if caching an invocation is skipped due to using date/time macros which makes the output non-deterministic.
417417
if enableDiagnosticRemarks {
418-
outputDelegate.remark("compilation was not cached for key: \(cacheKey)")
418+
outputDelegate.note("compilation was not cached for key: \(cacheKey)")
419419
}
420420
return
421421
}

Sources/SWBTaskExecution/TaskActions/SwiftCachingKeyQueryTaskAction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class SwiftCachingKeyQueryTaskAction: TaskAction {
4949
for cacheKey in key.cacheKeys {
5050
let cacheHit = try await cas.queryCacheKey(cacheKey, globally: true) != nil
5151
if key.casOptions.enableDiagnosticRemarks {
52-
outputDelegate.remark("cache key query \(cacheHit ? "hit" : "miss")")
52+
outputDelegate.note("cache key query \(cacheHit ? "hit" : "miss")")
5353
}
5454
guard cacheHit else {
5555
// return on first failure.
@@ -60,7 +60,7 @@ public final class SwiftCachingKeyQueryTaskAction: TaskAction {
6060
guard !key.casOptions.enableStrictCASErrors else { throw error }
6161
outputDelegate.warning(error.localizedDescription)
6262
if key.casOptions.enableDiagnosticRemarks {
63-
outputDelegate.remark("cache key query failed")
63+
outputDelegate.note("cache key query failed")
6464
}
6565
}
6666
return .succeeded

Sources/SWBTaskExecution/TaskActions/SwiftCachingOutputMaterializerTaskAction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public final class SwiftCachingOutputMaterializerTaskAction: TaskAction {
4949
do {
5050
let loaded = try await cas.download(with: key.casID)
5151
if !loaded && key.casOptions.enableDiagnosticRemarks {
52-
outputDelegate.remark("cached output \(key.casID) not found")
52+
outputDelegate.note("cached output \(key.casID) not found")
5353
}
5454
} catch {
5555
guard !key.casOptions.enableStrictCASErrors else { throw error }
5656
outputDelegate.warning(error.localizedDescription)
5757
if key.casOptions.enableDiagnosticRemarks {
58-
outputDelegate.remark("cached output \(key.casID) downloading failed")
58+
outputDelegate.note("cached output \(key.casID) downloading failed")
5959
}
6060
}
6161
return .succeeded

Sources/SWBTaskExecution/TaskActions/SwiftDriverJobTaskAction.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,24 +599,24 @@ public final class SwiftDriverJobTaskAction: TaskAction, BuildValueValidatingTas
599599
// If any of the key misses, return cache miss.
600600
guard let comp = try cas.queryLocalCacheKey(cacheKey) else {
601601
if enableDiagnosticRemarks {
602-
outputDelegate.remark("local cache miss for key: \(cacheKey)")
602+
outputDelegate.note("local cache miss for key: \(cacheKey)")
603603
}
604604
return false
605605
}
606606
if enableDiagnosticRemarks {
607-
outputDelegate.remark("local cache found for key: \(cacheKey)")
607+
outputDelegate.note("local cache found for key: \(cacheKey)")
608608
}
609609
// Check all outputs are materialized.
610610
// Doing the check immediately after the key allows associating the output remarks with the right key.
611611
for output in try comp.getOutputs() {
612612
if !output.isMaterialized {
613613
if enableDiagnosticRemarks {
614-
outputDelegate.remark("cached output \(output.kindName) not available locally: \(output.casID)")
614+
outputDelegate.note("cached output \(output.kindName) not available locally: \(output.casID)")
615615
}
616616
return false
617617
}
618618
if enableDiagnosticRemarks {
619-
outputDelegate.remark("using CAS output \(output.kindName): \(output.casID)")
619+
outputDelegate.note("using CAS output \(output.kindName): \(output.casID)")
620620
}
621621
}
622622
comps.append(comp)
@@ -642,7 +642,7 @@ public final class SwiftDriverJobTaskAction: TaskAction, BuildValueValidatingTas
642642

643643
let result = try await replayCachedCommandImpl()
644644
if enableDiagnosticRemarks {
645-
outputDelegate.remark("replay cache \(result ? "hit" : "miss")")
645+
outputDelegate.note("replay cache \(result ? "hit" : "miss")")
646646
}
647647
if result {
648648
outputDelegate.incrementSwiftCacheHit()

Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
16721672

16731673
results.check(contains: .activityStarted(ruleInfo: "ClangCachingPruneData \(path.str)/builtin \(libClangPath.str)"))
16741674
results.check(contains: .activityEnded(ruleInfo: "ClangCachingPruneData \(path.str)/builtin \(libClangPath.str)", status: .succeeded))
1675-
results.checkRemark(.contains("cache miss: "))
1675+
results.checkNote(.contains("cache miss: "))
16761676
results.checkNoRemarks()
16771677
}
16781678

@@ -1686,7 +1686,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
16861686
results.check(notContains: .activityEnded(ruleInfo: "CleanupCompileCache \(path.str)", status: .succeeded))
16871687

16881688
if canUseCASPruning {
1689-
results.checkRemark(.regex(try Regex("cache size \\(.*\\) larger than size limit")))
1689+
results.checkNote(.regex(try Regex("cache size \\(.*\\) larger than size limit")))
16901690
}
16911691
}
16921692

@@ -1708,7 +1708,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
17081708

17091709
results.check(contains: .activityStarted(ruleInfo: "ClangCachingPruneData \(path.str)/builtin \(libClangPath.str)"))
17101710
results.check(contains: .activityEnded(ruleInfo: "ClangCachingPruneData \(path.str)/builtin \(libClangPath.str)", status: .succeeded))
1711-
results.checkRemark(.contains("cache miss: "))
1711+
results.checkNote(.contains("cache miss: "))
17121712
results.checkNoRemarks()
17131713
}
17141714
}
@@ -1836,12 +1836,20 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests {
18361836
}
18371837

18381838
extension BuildOperationTester.BuildResults {
1839-
fileprivate func checkCompileCacheMiss(_ task: Task, file: StaticString = #file, line: UInt = #line) {
1840-
checkRemark(.contains("cache miss: "))
1839+
fileprivate func checkCompileCacheMiss(_ task: Task, sourceLocation: SourceLocation = #_sourceLocation) {
1840+
let found = (getDiagnosticMessageForTask(.contains("cache miss: "), kind: .note, task: task) != nil)
1841+
guard found else {
1842+
Issue.record("Unable to find cache miss diagnostic for task \(task)", sourceLocation: sourceLocation)
1843+
return
1844+
}
18411845
}
18421846

1843-
fileprivate func checkCompileCacheHit(_ task: Task, file: StaticString = #file, line: UInt = #line) {
1844-
checkRemark(.contains("cache hit: "))
1845-
while checkRemark(.contains("using CAS output"), failIfNotFound: false) {}
1847+
fileprivate func checkCompileCacheHit(_ task: Task, sourceLocation: SourceLocation = #_sourceLocation) {
1848+
let found = (getDiagnosticMessageForTask(.contains("cache hit: "), kind: .note, task: task) != nil)
1849+
guard found else {
1850+
Issue.record("Unable to find cache hit diagnostic for task \(task)", sourceLocation: sourceLocation)
1851+
return
1852+
}
1853+
while getDiagnosticMessageForTask(.contains("using CAS output"), kind: .note, task: task) != nil {}
18461854
}
18471855
}

Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ fileprivate struct SwiftCompilationCachingTests: CoreBasedTests {
201201

202202
extension BuildOperationTester.BuildResults {
203203
fileprivate func checkKeyQueryCacheMiss(_ task: Task, sourceLocation: SourceLocation = #_sourceLocation) {
204-
let found = (getDiagnosticMessageForTask(.contains("cache miss"), kind: .remark, task: task) != nil)
204+
let found = (getDiagnosticMessageForTask(.contains("cache miss"), kind: .note, task: task) != nil)
205205
guard found else {
206206
Issue.record("Unable to find cache miss diagnostic for task \(task)", sourceLocation: sourceLocation)
207207
return
208208
}
209209
}
210210

211211
fileprivate func checkKeyQueryCacheHit(_ task: Task, sourceLocation: SourceLocation = #_sourceLocation) {
212-
let found = (getDiagnosticMessageForTask(.contains("cache found for key"), kind: .remark, task: task) != nil)
212+
let found = (getDiagnosticMessageForTask(.contains("cache found for key"), kind: .note, task: task) != nil)
213213
guard found else {
214214
Issue.record("Unable to find cache hit diagnostic for task \(task)", sourceLocation: sourceLocation)
215215
return

0 commit comments

Comments
 (0)