Commit 817f11c
authored
Add heartbeat-based dynamic profiling system to intel repo (#1009)
* Add heartbeat-based dynamic profiling system
This PR introduces a heartbeat protocol that enables dynamic profiling
control. Agents periodically send heartbeats to a Performance Studio
backend and receive start/stop profiling commands, allowing on-demand
profiling without agent restarts.
Key features:
- HeartbeatClient for server communication
- DynamicGProfilerManager for profiler lifecycle management
- Command idempotency to prevent duplicate execution
- Support for dynamic profiler configuration
- PerfSpect hardware metrics integration
- Comprehensive test suite with mock and live modes
- Complete documentation with examples
Files added:
- gprofiler/heartbeat.py (627 lines)
- docs/HEARTBEAT_SYSTEM_README.md (634 lines)
- tests/test_heartbeat_system.py (358 lines)
- tests/run_heartbeat_agent.py (136 lines)
Files modified:
- gprofiler/main.py (heartbeat initialization)
Source: Pinterest's gprofiler repository
Testing: Mock tests pass, live tests verified with backend
* Remove metrics_publisher dependency for Intel compatibility
Removed Pinterest-specific MetricsPublisher imports and calls.
requiring additional Pinterest-specific dependencies.
* WIP: Add cgroup support and upgrade PyInstaller
* Enable cgroup-based profiling for perf restricted/aggressive modes
* Address PR review comments: improve error handling and logging
- Remove redundant upload_results validation check in main.py
- Change heartbeat failure logging from warning to error for better monitoring
- Separate success and error cases in send_heartbeat() response handling
- Reduce duplicate logging: change redundant 'Received profiling command' to debug level
- Validate command type before marking as executed to ensure proper idempotency
- Add unified error handling for start/stop command execution with try-except
- Ensure backend always receives command completion status (success or failure)
- Keep command details logging for operational visibility
Addresses all review comments from @mlim19 on PR #1009.
* Fix linting issues for CI compliance
- Fix import sorting and code formatting
- Remove unused imports and variables
- Add missing logging import to profiler_base.py
* Fixed by ensuring -a comes before -- in the perf command
* Improve heartbeat mode logging with clearer status messages after stop command1 parent 37e6acc commit 817f11c
13 files changed
Lines changed: 2705 additions & 34 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
| 172 | + | |
170 | 173 | | |
171 | 174 | | |
172 | 175 | | |
| |||
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
282 | 305 | | |
283 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
284 | 316 | | |
285 | 317 | | |
286 | 318 | | |
| |||
594 | 626 | | |
595 | 627 | | |
596 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
597 | 648 | | |
598 | 649 | | |
599 | 650 | | |
| |||
861 | 912 | | |
862 | 913 | | |
863 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
864 | 931 | | |
865 | 932 | | |
866 | 933 | | |
| |||
936 | 1003 | | |
937 | 1004 | | |
938 | 1005 | | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
939 | 1014 | | |
940 | 1015 | | |
941 | 1016 | | |
| |||
1215 | 1290 | | |
1216 | 1291 | | |
1217 | 1292 | | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1247 | 1315 | | |
1248 | | - | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
1249 | 1348 | | |
1250 | 1349 | | |
1251 | 1350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
128 | 152 | | |
129 | 153 | | |
130 | 154 | | |
| |||
138 | 162 | | |
139 | 163 | | |
140 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
141 | 169 | | |
142 | 170 | | |
143 | 171 | | |
| |||
148 | 176 | | |
149 | 177 | | |
150 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
151 | 182 | | |
152 | 183 | | |
153 | 184 | | |
| |||
159 | 190 | | |
160 | 191 | | |
161 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
162 | 199 | | |
163 | 200 | | |
164 | 201 | | |
| |||
184 | 221 | | |
185 | 222 | | |
186 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
187 | 227 | | |
188 | 228 | | |
189 | 229 | | |
| |||
200 | 240 | | |
201 | 241 | | |
202 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
203 | 246 | | |
204 | 247 | | |
205 | 248 | | |
| |||
0 commit comments