Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Improved performance serializing profiling data (#2863)
- Possible crash in Core Data tracking (#2865)
- Ensure the current GPU frame rate is always reported for concurrent transaction profiling metrics (#2929)
- Move profiler metric collection to a background queue (#2956)

## 8.5.0

Expand Down
24 changes: 24 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,12 @@
84A8891C28DBD28900C51DFD /* SentryDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A8891A28DBD28900C51DFD /* SentryDevice.h */; };
84A8891D28DBD28900C51DFD /* SentryDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84A8891B28DBD28900C51DFD /* SentryDevice.mm */; };
84A8892128DBD8D600C51DFD /* SentryDeviceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84A8892028DBD8D600C51DFD /* SentryDeviceTests.mm */; };
84AC61D229F7541E009EEF61 /* SentryDispatchSourceWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AC61D029F7541E009EEF61 /* SentryDispatchSourceWrapper.h */; };
84AC61D329F7541E009EEF61 /* SentryDispatchSourceWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AC61D129F7541E009EEF61 /* SentryDispatchSourceWrapper.m */; };
84AC61D629F75A98009EEF61 /* SentryDispatchFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AC61D429F75A98009EEF61 /* SentryDispatchFactory.h */; };
84AC61D729F75A98009EEF61 /* SentryDispatchFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AC61D529F75A98009EEF61 /* SentryDispatchFactory.m */; };
84AC61D929F7643B009EEF61 /* TestDispatchFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AC61D829F7643B009EEF61 /* TestDispatchFactory.swift */; };
84AC61DB29F7654A009EEF61 /* TestDispatchSourceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AC61DA29F7654A009EEF61 /* TestDispatchSourceWrapper.swift */; };
84AF45A629A7FFA500FBB177 /* SentryTracerConcurrency.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AF45A429A7FFA500FBB177 /* SentryTracerConcurrency.h */; };
84AF45A729A7FFA500FBB177 /* SentryTracerConcurrency.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84AF45A529A7FFA500FBB177 /* SentryTracerConcurrency.mm */; };
84B7FA3529B285FC00AD93B1 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63AA759B1EB8AEF500D153DE /* Sentry.framework */; };
Expand Down Expand Up @@ -1553,6 +1559,12 @@
84A8891A28DBD28900C51DFD /* SentryDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDevice.h; path = include/SentryDevice.h; sourceTree = "<group>"; };
84A8891B28DBD28900C51DFD /* SentryDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryDevice.mm; sourceTree = "<group>"; };
84A8892028DBD8D600C51DFD /* SentryDeviceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryDeviceTests.mm; sourceTree = "<group>"; };
84AC61D029F7541E009EEF61 /* SentryDispatchSourceWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDispatchSourceWrapper.h; path = include/SentryDispatchSourceWrapper.h; sourceTree = "<group>"; };
84AC61D129F7541E009EEF61 /* SentryDispatchSourceWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDispatchSourceWrapper.m; sourceTree = "<group>"; };
84AC61D429F75A98009EEF61 /* SentryDispatchFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDispatchFactory.h; path = include/SentryDispatchFactory.h; sourceTree = "<group>"; };
84AC61D529F75A98009EEF61 /* SentryDispatchFactory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDispatchFactory.m; sourceTree = "<group>"; };
84AC61D829F7643B009EEF61 /* TestDispatchFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDispatchFactory.swift; sourceTree = "<group>"; };
84AC61DA29F7654A009EEF61 /* TestDispatchSourceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDispatchSourceWrapper.swift; sourceTree = "<group>"; };
84AF45A429A7FFA500FBB177 /* SentryTracerConcurrency.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTracerConcurrency.h; path = include/SentryTracerConcurrency.h; sourceTree = "<group>"; };
84AF45A529A7FFA500FBB177 /* SentryTracerConcurrency.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryTracerConcurrency.mm; sourceTree = "<group>"; };
84B7FA3B29B2866200AD93B1 /* SentryTestUtils-ObjC-BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryTestUtils-ObjC-BridgingHeader.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1835,6 +1847,10 @@
638DC99F1EBC6B6400A66E41 /* SentryRequestOperation.m */,
7BDB03B6251364F800BAE198 /* SentryDispatchQueueWrapper.h */,
7BDB03BA2513652900BAE198 /* SentryDispatchQueueWrapper.m */,
84AC61D029F7541E009EEF61 /* SentryDispatchSourceWrapper.h */,
84AC61D429F75A98009EEF61 /* SentryDispatchFactory.h */,
84AC61D529F75A98009EEF61 /* SentryDispatchFactory.m */,
84AC61D129F7541E009EEF61 /* SentryDispatchSourceWrapper.m */,
0AAE202028ED9BCC00D0CD80 /* SentryReachability.h */,
0AAE201D28ED9B9400D0CD80 /* SentryReachability.m */,
);
Expand Down Expand Up @@ -3105,6 +3121,8 @@
isa = PBXGroup;
children = (
7BD47B4C268F0B080076A663 /* ClearTestState.swift */,
84AC61D829F7643B009EEF61 /* TestDispatchFactory.swift */,
84AC61DA29F7654A009EEF61 /* TestDispatchSourceWrapper.swift */,
84A5D75A29D5170700388BFA /* TimeInterval+Sentry.swift */,
7B30B68126527C55006B2752 /* TestDisplayLinkWrapper.swift */,
8E25C97425F8511A00DC215B /* TestRandom.swift */,
Expand Down Expand Up @@ -3361,6 +3379,7 @@
7B82D54524E2A05500EE670F /* SentryId.h in Headers */,
D867063D27C3BC2400048851 /* SentryCoreDataTrackingIntegration.h in Headers */,
0A2D8D5D289815EB008720F6 /* SentryBaseIntegration.h in Headers */,
84AC61D629F75A98009EEF61 /* SentryDispatchFactory.h in Headers */,
63FE716520DA4C1100CDBAE8 /* SentryCrashMemory.h in Headers */,
63FE713F20DA4C1100CDBAE8 /* SentryCrashStackCursor_SelfThread.h in Headers */,
639FCFA41EBC809A00778193 /* SentryStacktrace.h in Headers */,
Expand Down Expand Up @@ -3485,6 +3504,7 @@
632331F9240506DF008D91D6 /* SentryScope+Private.h in Headers */,
D8603DD8284F894C000E1227 /* SentryBaggage.h in Headers */,
03F84D2127DD414C008FE43F /* SentrySamplingProfiler.hpp in Headers */,
84AC61D229F7541E009EEF61 /* SentryDispatchSourceWrapper.h in Headers */,
63FE712B20DA4C1100CDBAE8 /* SentryCrashStackCursor.h in Headers */,
D8C67E9C28000E24007E326E /* SentryScreenshot.h in Headers */,
7BA61CBF247CEA8100C130A8 /* SentryFormatter.h in Headers */,
Expand Down Expand Up @@ -3894,6 +3914,7 @@
63FE712920DA4C1000CDBAE8 /* SentryCrashCPU_arm.c in Sources */,
03F84D3427DD4191008FE43F /* SentryThreadMetadataCache.cpp in Sources */,
7B88F30024BC5A7D00ADF90A /* SentrySdkInfo.m in Sources */,
84AC61D729F75A98009EEF61 /* SentryDispatchFactory.m in Sources */,
15360CD62432832400112302 /* SentryAutoSessionTrackingIntegration.m in Sources */,
7B63459F280EBA7200CFA05A /* SentryUIEventTracker.m in Sources */,
7BF9EF782722B35D00B5BBEF /* SentrySubClassFinder.m in Sources */,
Expand Down Expand Up @@ -4010,6 +4031,7 @@
7BB65501253DC1B500887E87 /* SentryUserFeedback.m in Sources */,
7D5C441A237C2E1F00DAB0A3 /* SentrySDK.m in Sources */,
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */,
84AC61D329F7541E009EEF61 /* SentryDispatchSourceWrapper.m in Sources */,
63FE712D20DA4C1100CDBAE8 /* SentryCrashJSONCodecObjC.m in Sources */,
7BBD18932449BEDD00427C76 /* SentryDefaultRateLimits.m in Sources */,
7BD729982463E93500EA3610 /* SentryDateUtil.m in Sources */,
Expand Down Expand Up @@ -4341,6 +4363,7 @@
84B7FA4229B28CDE00AD93B1 /* TestCurrentDateProvider.swift in Sources */,
84B7FA3F29B28BAD00AD93B1 /* TestTransport.swift in Sources */,
84A5D75B29D5170700388BFA /* TimeInterval+Sentry.swift in Sources */,
84AC61D929F7643B009EEF61 /* TestDispatchFactory.swift in Sources */,
8431F01929B2852D00D8DC56 /* Invocation.swift in Sources */,
84B7FA4629B2935F00AD93B1 /* ClearTestState.swift in Sources */,
8431F01529B2851500D8DC56 /* TestSentryNSTimerWrapper.swift in Sources */,
Expand All @@ -4352,6 +4375,7 @@
8431F01B29B2852D00D8DC56 /* Logger.swift in Sources */,
8431F01829B2852D00D8DC56 /* TypeMapping.swift in Sources */,
84B7FA4529B2926900AD93B1 /* TestDisplayLinkWrapper.swift in Sources */,
84AC61DB29F7654A009EEF61 /* TestDispatchSourceWrapper.swift in Sources */,
8431F01729B2851500D8DC56 /* TestSentrySystemWrapper.swift in Sources */,
84B7FA4129B28CD200AD93B1 /* TestSentryDispatchQueueWrapper.swift in Sources */,
84B7FA3E29B28ADD00AD93B1 /* TestClient.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#import "SentryCurrentDateProvider.h"
#import "SentryDefines.h"
#import "SentryDependencyContainer.h"
#import "SentryDispatchFactory.h"
#import "SentryDispatchQueueWrapper.h"
#import "SentryDispatchSourceWrapper.h"
#import "SentryDisplayLinkWrapper.h"
#import "SentryEnvelope.h"
#import "SentryFileManager.h"
Expand Down
19 changes: 19 additions & 0 deletions SentryTestUtils/TestDispatchFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation
import Sentry

public class TestDispatchFactory: SentryDispatchFactory {
public var vendedSourceHandler: ((TestDispatchSourceWrapper) -> Void)?
public var vendedQueueHandler: ((TestSentryDispatchQueueWrapper) -> Void)?

public override func queue(withName name: UnsafePointer<CChar>, attributes: __OS_dispatch_queue_attr) -> SentryDispatchQueueWrapper {
let queue = TestSentryDispatchQueueWrapper(name: name, attributes: attributes)
vendedQueueHandler?(queue)
return queue
}

public override func source(withInterval interval: UInt64, leeway: UInt64, queueName: UnsafePointer<CChar>, attributes: __OS_dispatch_queue_attr, eventHandler: @escaping () -> Void) -> SentryDispatchSourceWrapper {
let source = TestDispatchSourceWrapper(eventHandler: eventHandler)
vendedSourceHandler?(source)
return source
}
}
22 changes: 22 additions & 0 deletions SentryTestUtils/TestDispatchSourceWrapper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Foundation
import Sentry

public class TestDispatchSourceWrapper: SentryDispatchSourceWrapper {
public struct Override {
public var eventHandler: (() -> Void)?
}
public var overrides = Override()

public init(eventHandler: @escaping () -> Void) {
self.overrides.eventHandler = eventHandler
super.init()
}

public override func cancel() {
// no-op
}

public func fire() {
self.overrides.eventHandler?()
}
}
26 changes: 26 additions & 0 deletions Sources/Sentry/SentryDispatchFactory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import "SentryDispatchFactory.h"
#import "SentryDispatchQueueWrapper.h"
#import "SentryDispatchSourceWrapper.h"

@implementation SentryDispatchFactory

- (SentryDispatchQueueWrapper *)queueWithName:(const char *)name
attributes:(dispatch_queue_attr_t)attributes
{
return [[SentryDispatchQueueWrapper alloc] initWithName:name attributes:attributes];
}

- (SentryDispatchSourceWrapper *)sourceWithInterval:(uint64_t)interval
leeway:(uint64_t)leeway
queueName:(const char *)queueName
attributes:(dispatch_queue_attr_t)attributes
eventHandler:(void (^)(void))eventHandler
{
return [[SentryDispatchSourceWrapper alloc]
initTimerWithInterval:interval
leeway:leeway
queue:[self queueWithName:queueName attributes:attributes]
eventHandler:eventHandler];
}

@end
14 changes: 4 additions & 10 deletions Sources/Sentry/SentryDispatchQueueWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

NS_ASSUME_NONNULL_BEGIN

@implementation SentryDispatchQueueWrapper {
// Don't use a normal property because on RN a user got a warning "Property with 'retain (or
// strong)' attribute must be of object type". A dispatch queue is since iOS 6.0 an NSObject so
// it should work with strong, but nevertheless, we use an instance variable to fix this
// warning.
dispatch_queue_t queue;
}
Comment on lines -6 to -12
Copy link
Member Author

Choose a reason for hiding this comment

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

This is no longer true since we bumped our min supported version. I believe we can also change this:

// DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL is requires iOS 10. Since we are targeting
// iOS 9 we need to manually add the autoreleasepool.

This is now exposed as a property in the public interface so it can be accessed when setting up a new dispatch_source_t in SentryDispatchSourceWrapper[

@implementation SentryDispatchQueueWrapper

- (instancetype)init
{
Expand All @@ -24,14 +18,14 @@ - (instancetype)init
- (instancetype)initWithName:(const char *)name attributes:(dispatch_queue_attr_t)attributes;
{
if (self = [super init]) {
queue = dispatch_queue_create(name, attributes);
_queue = dispatch_queue_create(name, attributes);
}
return self;
}

- (void)dispatchAsyncWithBlock:(void (^)(void))block
{
dispatch_async(queue, ^{
dispatch_async(_queue, ^{
@autoreleasepool {
block();
}
Expand Down Expand Up @@ -60,7 +54,7 @@ - (void)dispatchAfter:(NSTimeInterval)interval block:(dispatch_block_t)block
{
dispatch_time_t delta = (int64_t)(interval * NSEC_PER_SEC);
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, delta);
dispatch_after(when, queue, ^{
dispatch_after(when, _queue, ^{
@autoreleasepool {
block();
}
Expand Down
30 changes: 30 additions & 0 deletions Sources/Sentry/SentryDispatchSourceWrapper.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#import "SentryDispatchSourceWrapper.h"
#import "SentryDispatchQueueWrapper.h"

@implementation SentryDispatchSourceWrapper {
SentryDispatchQueueWrapper *_queueWrapper;
dispatch_source_t _source;
}

- (instancetype)initTimerWithInterval:(uint64_t)interval
leeway:(uint64_t)leeway
queue:(SentryDispatchQueueWrapper *)queueWrapper
eventHandler:(void (^)(void))eventHandler
{
if (self = [super init]) {
_queueWrapper = queueWrapper;
_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queueWrapper.queue);
dispatch_source_set_event_handler(_source, eventHandler);
dispatch_source_set_timer(
_source, dispatch_time(DISPATCH_TIME_NOW, interval), interval, leeway);
dispatch_resume(_source);
}
return self;
}

- (void)cancel
{
dispatch_cancel(_source);
}

@end
60 changes: 36 additions & 24 deletions Sources/Sentry/SentryMetricProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryCurrentDate.h"
# import "SentryDispatchFactory.h"
# import "SentryDispatchQueueWrapper.h"
# import "SentryDispatchSourceWrapper.h"
# import "SentryEvent+Private.h"
# import "SentryFormatter.h"
# import "SentryLog.h"
Expand All @@ -23,19 +26,18 @@ @interface SentryMetricReading : NSObject
@implementation SentryMetricReading
@end

/**
* Currently set to 10 Hz as we don't anticipate much utility out of a higher resolution when
* sampling CPU usage and memory footprint, and we want to minimize the overhead of making the
* necessary system calls to gather that information.
*/
static const NSTimeInterval kSentryMetricProfilerTimeseriesInterval = 0.1;

NSString *const kSentryMetricProfilerSerializationKeyMemoryFootprint = @"memory_footprint";
NSString *const kSentryMetricProfilerSerializationKeyCPUUsageFormat = @"cpu_usage_%d";

NSString *const kSentryMetricProfilerSerializationUnitBytes = @"byte";
NSString *const kSentryMetricProfilerSerializationUnitPercentage = @"percent";

// Currently set to 10 Hz as we don't anticipate much utility out of a higher resolution when
// sampling CPU usage and memory footprint, and we want to minimize the overhead of making the
// necessary system calls to gather that information. This is currently roughly 10% of the
// backtrace profiler's resolution.
static uint64_t frequencyHz = 10;

namespace {
/**
* @return a dictionary containing all the metric values recorded during the transaction, or @c nil
Expand Down Expand Up @@ -74,11 +76,11 @@ @implementation SentryMetricReading
} // namespace

@implementation SentryMetricProfiler {
NSTimer *_timer;
SentryDispatchSourceWrapper *_dispatchSource;

SentryNSProcessInfoWrapper *_processInfoWrapper;
SentrySystemWrapper *_systemWrapper;
SentryNSTimerWrapper *_timerWrapper;
SentryDispatchFactory *_dispatchFactory;

/// arrays of readings keyed on NSNumbers representing the core number for the set of readings
NSMutableDictionary<NSNumber *, NSMutableArray<SentryMetricReading *> *> *_cpuUsage;
Expand All @@ -88,7 +90,7 @@ @implementation SentryMetricProfiler {

- (instancetype)initWithProcessInfoWrapper:(SentryNSProcessInfoWrapper *)processInfoWrapper
systemWrapper:(SentrySystemWrapper *)systemWrapper
timerWrapper:(SentryNSTimerWrapper *)timerWrapper
dispatchFactory:(nonnull SentryDispatchFactory *)dispatchFactory
{
if (self = [super init]) {
_cpuUsage =
Expand All @@ -102,7 +104,7 @@ - (instancetype)initWithProcessInfoWrapper:(SentryNSProcessInfoWrapper *)process

_systemWrapper = systemWrapper;
_processInfoWrapper = processInfoWrapper;
_timerWrapper = timerWrapper;
_dispatchFactory = dispatchFactory;

_memoryFootprint = [NSMutableArray<SentryMetricReading *> array];
}
Expand All @@ -123,24 +125,28 @@ - (void)start

- (void)stop
{
[_timer invalidate];
[_dispatchSource cancel];
}

- (NSMutableDictionary<NSString *, id> *)serializeForTransaction:(SentryTransaction *)transaction
{
NSMutableDictionary<NSString *, id> *dict;
NSArray<SentryMetricReading *> *memoryFootprint;
NSDictionary<NSNumber *, NSArray<SentryMetricReading *> *> *cpuUsage;
@synchronized(self) {
dict = [NSMutableDictionary<NSString *, id> dictionary];
memoryFootprint = [NSArray<SentryMetricReading *> arrayWithArray:_memoryFootprint];
cpuUsage = [NSDictionary<NSNumber *, NSArray<SentryMetricReading *> *>
dictionaryWithDictionary:_cpuUsage];
}

if (_memoryFootprint.count > 0) {
const auto dict = [NSMutableDictionary<NSString *, id> dictionary];
if (memoryFootprint.count > 0) {
dict[kSentryMetricProfilerSerializationKeyMemoryFootprint]
= serializeValuesWithNormalizedTime(
_memoryFootprint, kSentryMetricProfilerSerializationUnitBytes, transaction);
memoryFootprint, kSentryMetricProfilerSerializationUnitBytes, transaction);
}

[_cpuUsage enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull core,
NSMutableArray<SentryMetricReading *> *_Nonnull readings, BOOL *_Nonnull stop) {
[cpuUsage enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull core,
NSArray<SentryMetricReading *> *_Nonnull readings, BOOL *_Nonnull stop) {
if (readings.count > 0) {
dict[[NSString stringWithFormat:kSentryMetricProfilerSerializationKeyCPUUsageFormat,
core.intValue]]
Expand All @@ -157,12 +163,18 @@ - (void)stop
- (void)registerSampler
{
__weak auto weakSelf = self;
_timer = [_timerWrapper scheduledTimerWithTimeInterval:kSentryMetricProfilerTimeseriesInterval
repeats:YES
block:^(NSTimer *_Nonnull timer) {
[weakSelf recordCPUPercentagePerCore];
[weakSelf recordMemoryFootprint];
}];
const auto intervalNs = (uint64_t)1e9 / frequencyHz;
const auto leewayNs = intervalNs / 2;
_dispatchSource =
[_dispatchFactory sourceWithInterval:intervalNs
leeway:leewayNs
queueName:"io.sentry.metric-profiler"
attributes:dispatch_queue_attr_make_with_qos_class(
DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_UTILITY, 0)
eventHandler:^{
[weakSelf recordCPUPercentagePerCore];
[weakSelf recordMemoryFootprint];
Comment on lines +175 to +176
Copy link
Member

Choose a reason for hiding this comment

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

recordCPUPercentagePerCore and recordMemoryFootprint were previously called on the main thread, are they thread safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. Their calls to task_info and host_processor_info are not synchronized, but their modifications of the data structure those readings are stored in are inside @synchronized blocks. Is this safe, or do you think we should move the task_info/host_processor_info calls inside the synchronization as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

i improved the method that reads from the data structure as well in adef4bc

}];
}

- (void)recordMemoryFootprint
Expand Down
Loading