File tree Expand file tree Collapse file tree 3 files changed +23
-14
lines changed
ProfileRecorderSampleConversion Expand file tree Collapse file tree 3 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ socket_path="$tmpdir/swipr.sock"
1616PROFILE_RECORDER_SERVER_URL=unix://" $socket_path " \
1717 " $tmpdir " /build/release/swipr-mini-demo \
1818 --blocking --burn-cpu --array-appends \
19+ --tsp true \
1920 --output " $output " /samples.swipr \
2021 --iterations 1000 \
2122 --profiling-server &
Original file line number Diff line number Diff line change 1313//===----------------------------------------------------------------------===//
1414
1515import ProfileRecorder
16+ import ProfileRecorderHelpers
1617import Logging
1718import NIO
1819import _NIOFileSystem
@@ -119,17 +120,22 @@ extension ProfileRecorderSampler {
119120 _ body: ( String ) async throws -> R
120121 ) async throws -> R {
121122 let symbolizer = ProfileRecorderSampler . _makeDefaultSymbolizer ( )
122- try symbolizer. start ( )
123- defer {
124- try ! symbolizer. shutdown ( )
123+ try await NIOThreadPool . singleton. runIfActive {
124+ try symbolizer. start ( )
125+ }
126+ return try await asyncDo {
127+ return try await self . _withSamples (
128+ sampleCount: sampleCount,
129+ timeBetweenSamples: timeBetweenSamples,
130+ format: . perfSymbolized,
131+ symbolizer: symbolizer,
132+ logger: logger,
133+ body
134+ )
135+ } finally: { _ in
136+ try await NIOThreadPool . singleton. runIfActive {
137+ try symbolizer. shutdown ( )
138+ }
125139 }
126- return try await self . _withSamples (
127- sampleCount: sampleCount,
128- timeBetweenSamples: timeBetweenSamples,
129- format: . perfSymbolized,
130- symbolizer: symbolizer,
131- logger: logger,
132- body
133- )
134140 }
135141}
Original file line number Diff line number Diff line change @@ -319,9 +319,8 @@ public struct ProfileRecorderServer: Sendable {
319319 }
320320
321321 let symbolizer = ProfileRecorderSampler . _makeDefaultSymbolizer ( )
322- try symbolizer. start ( )
323- defer {
324- try ! symbolizer. shutdown ( )
322+ try await NIOThreadPool . singleton. runIfActive {
323+ try symbolizer. start ( )
325324 }
326325
327326 return try await asyncDo {
@@ -399,6 +398,9 @@ public struct ProfileRecorderServer: Sendable {
399398 if let udsPath = configuration. unixDomainSocketPath {
400399 _ = try ? await FileSystem . shared. removeItem ( at: FilePath ( udsPath) )
401400 }
401+ try await NIOThreadPool . singleton. runIfActive {
402+ try symbolizer. shutdown ( )
403+ }
402404 }
403405 }
404406
You can’t perform that action at this time.
0 commit comments