|
| 1 | +--- |
| 2 | +title: "iOS SDK Performance Impact" |
| 3 | +description: "This document describes the performance impact of the Flashcat iOS RUM SDK on your application." |
| 4 | +date: "2024-05-09T10:00:00+08:00" |
| 5 | +url: "https://docs.flashcat.cloud/en/flashduty/rum/ios-sdk-performance-impact" |
| 6 | +--- |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +When integrating any SDK into an iOS application, understanding its performance impact is crucial for maintaining a good user experience. The Flashcat RUM SDK is designed with the goal of minimizing performance overhead and provides transparent measurement data to help you evaluate whether the SDK meets your application's performance budget. |
| 11 | + |
| 12 | +## Performance Benchmark |
| 13 | + |
| 14 | +To evaluate the actual performance impact of the SDK on your application, we conducted performance benchmarks under typical usage scenarios. The following SDK features were enabled during testing: |
| 15 | + |
| 16 | +- Basic RUM monitoring: View, action, and resource tracking |
| 17 | +- Distributed tracing |
| 18 | + |
| 19 | +The SDK was initialized with default configuration and simulated common user operations (such as page views, scrolling lists, network requests, etc.). |
| 20 | + |
| 21 | +### Test Results |
| 22 | + |
| 23 | +| Metric | With SDK | Without SDK | Impact | |
| 24 | +| --- | --- | --- | --- | |
| 25 | +| Peak CPU Usage | ~44% | ~40% | +4% | |
| 26 | +| Peak Memory Usage | ~72 MB | ~68 MB | +4 MB | |
| 27 | +| App Launch Time | ~0.9 ms | ~0.65 ms | +0.25 ms | |
| 28 | +| Package Size | +1.4 MB | - | ~1.4 MB | |
| 29 | +| Network Usage | ~22 KB sent / ~2 KB received | - | Varies with event volume | |
| 30 | + |
| 31 | +**Notes**: |
| 32 | + |
| 33 | +- The above data are reference values under typical scenarios; actual impact may vary depending on application complexity, device performance, and SDK configuration |
| 34 | +- Launch time increase is minimal and barely perceptible to users |
| 35 | +- Network traffic depends on the number of collected events and sampling rate configuration |
| 36 | + |
| 37 | +### Performance Impact Details |
| 38 | + |
| 39 | +#### CPU Usage |
| 40 | + |
| 41 | +The SDK's CPU impact primarily comes from: |
| 42 | +- Event collection and processing |
| 43 | +- Data batching and compression |
| 44 | +- Network request reporting |
| 45 | + |
| 46 | +The SDK uses asynchronous processing mechanisms, with all data processing performed in background queues without blocking the main thread, ensuring it does not affect the application's UI responsiveness. |
| 47 | + |
| 48 | +#### Memory Usage |
| 49 | + |
| 50 | +The SDK uses a fixed-size memory buffer to store pending event data, which does not grow indefinitely over time. Stale data is automatically cleaned up to ensure it does not consume excessive memory. |
| 51 | + |
| 52 | +#### Launch Time |
| 53 | + |
| 54 | +The SDK initialization process is optimized, with impact on application launch time controlled to sub-millisecond level. It is recommended to initialize the SDK as early as possible in `AppDelegate`'s `didFinishLaunchingWithOptions` to capture the complete application startup process. |
| 55 | + |
| 56 | +#### Package Size |
| 57 | + |
| 58 | +The SDK uses a modular design, allowing you to include only the necessary functional modules: |
| 59 | + |
| 60 | +- `FlashcatCore`: Core functionality (required) |
| 61 | +- `FlashcatRUM`: RUM monitoring |
| 62 | +- `FlashcatTrace`: Distributed tracing |
| 63 | +- `FlashcatWebView`: WebView tracking |
| 64 | + |
| 65 | +Including only the necessary modules can minimize the impact on package size. |
| 66 | + |
| 67 | +#### Network Usage |
| 68 | + |
| 69 | +The SDK employs the following strategies to optimize network usage: |
| 70 | +- **Batch reporting**: Events are cached locally first and sent in batches to reduce the number of network requests |
| 71 | +- **Data compression**: Reported data is compressed to reduce transmission traffic |
| 72 | +- **Intelligent scheduling**: Upload timing is intelligently scheduled based on network status and battery level |
| 73 | + |
| 74 | +## Continuous Performance Monitoring |
| 75 | + |
| 76 | +Performance regression testing is conducted before each SDK release to ensure new versions do not introduce performance issues. |
| 77 | + |
| 78 | +### Performance Optimization Recommendations |
| 79 | + |
| 80 | +If you have specific performance requirements, consider the following optimization measures: |
| 81 | + |
| 82 | +1. **Adjust sampling rate**: Reduce the number of collected events by configuring the sampling rate |
| 83 | + |
| 84 | +```swift |
| 85 | +RUM.enable( |
| 86 | + with: RUM.Configuration( |
| 87 | + applicationID: "<RUM_APPLICATION_ID>", |
| 88 | + sessionSampleRate: 80 // Sample 80% of sessions |
| 89 | + ) |
| 90 | +) |
| 91 | +``` |
| 92 | + |
| 93 | +2. **Enable features on demand**: Only enable necessary tracking features |
| 94 | + |
| 95 | +```swift |
| 96 | +RUM.enable( |
| 97 | + with: RUM.Configuration( |
| 98 | + applicationID: "<RUM_APPLICATION_ID>", |
| 99 | + uiKitViewsPredicate: nil, // Disable automatic view tracking |
| 100 | + uiKitActionsPredicate: nil // Disable automatic action tracking |
| 101 | + ) |
| 102 | +) |
| 103 | +``` |
| 104 | + |
| 105 | +3. **Disable background event tracking**: If you don't need to track background events |
| 106 | + |
| 107 | +```swift |
| 108 | +RUM.enable( |
| 109 | + with: RUM.Configuration( |
| 110 | + applicationID: "<RUM_APPLICATION_ID>", |
| 111 | + trackBackgroundEvents: false |
| 112 | + ) |
| 113 | +) |
| 114 | +``` |
| 115 | + |
| 116 | +## Offline Data Storage |
| 117 | + |
| 118 | +When the device is offline, the SDK stores data locally with strict storage space limits: |
| 119 | + |
| 120 | +- Uses fixed-size disk cache |
| 121 | +- Expired data is automatically cleaned up |
| 122 | +- Cached data will not affect device storage space |
| 123 | + |
| 124 | +## Battery Consumption |
| 125 | + |
| 126 | +The SDK is designed with battery consumption in mind: |
| 127 | + |
| 128 | +- Automatically reduces upload frequency when battery level falls below a certain threshold |
| 129 | +- Leverages system background task mechanisms for data reporting |
| 130 | +- Avoids frequent device wake-ups |
| 131 | + |
| 132 | +## Related Documentation |
| 133 | + |
| 134 | +- [iOS SDK Integration Guide](https://docs.flashcat.cloud/en/flashduty/rum/ios-sdk-integration): Learn how to integrate the SDK |
| 135 | +- [iOS SDK Advanced Configuration](https://docs.flashcat.cloud/en/flashduty/rum/ios-advanced-configuration): Learn about SDK advanced configuration options |
| 136 | +- [iOS SDK Data Collection](https://docs.flashcat.cloud/en/flashduty/rum/ios-data-collected): Learn what data the SDK collects |
| 137 | +- [iOS SDK Compatibility](https://docs.flashcat.cloud/en/flashduty/rum/ios-compatibility): Learn about supported platform versions |
0 commit comments