Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
e8acd2e7
by Wen Kokke at 2025-07-16T08:37:04-04:00
-
76d392a2
by Wen Kokke at 2025-07-16T08:37:04-04:00
6 changed files:
- rts/ProfHeap.c
- rts/RetainerSet.c
- rts/Trace.c
- rts/Trace.h
- rts/eventlog/EventLog.c
- rts/eventlog/EventLog.h
Changes:
| ... | ... | @@ -557,7 +557,7 @@ initHeapProfiling(void) |
| 557 | 557 | |
| 558 | 558 | restore_locale();
|
| 559 | 559 | |
| 560 | - traceHeapProfBegin(0);
|
|
| 560 | + traceInitEvent(traceHeapProfBegin);
|
|
| 561 | 561 | }
|
| 562 | 562 | |
| 563 | 563 | void
|
| ... | ... | @@ -896,17 +896,17 @@ dumpCensus( Census *census ) |
| 896 | 896 | |
| 897 | 897 | |
| 898 | 898 | // Eventlog
|
| 899 | - traceHeapProfSampleString(0, "VOID",
|
|
| 899 | + traceHeapProfSampleString("VOID",
|
|
| 900 | 900 | (census->void_total * sizeof(W_)));
|
| 901 | - traceHeapProfSampleString(0, "LAG",
|
|
| 901 | + traceHeapProfSampleString("LAG",
|
|
| 902 | 902 | ((census->not_used - census->void_total) *
|
| 903 | 903 | sizeof(W_)));
|
| 904 | - traceHeapProfSampleString(0, "USE",
|
|
| 904 | + traceHeapProfSampleString("USE",
|
|
| 905 | 905 | ((census->used - census->drag_total) *
|
| 906 | 906 | sizeof(W_)));
|
| 907 | - traceHeapProfSampleString(0, "INHERENT_USE",
|
|
| 907 | + traceHeapProfSampleString("INHERENT_USE",
|
|
| 908 | 908 | (census->prim * sizeof(W_)));
|
| 909 | - traceHeapProfSampleString(0, "DRAG",
|
|
| 909 | + traceHeapProfSampleString("DRAG",
|
|
| 910 | 910 | (census->drag_total * sizeof(W_)));
|
| 911 | 911 | |
| 912 | 912 | traceHeapProfSampleEnd(era);
|
| ... | ... | @@ -941,33 +941,33 @@ dumpCensus( Census *census ) |
| 941 | 941 | switch (RtsFlags.ProfFlags.doHeapProfile) {
|
| 942 | 942 | case HEAP_BY_CLOSURE_TYPE:
|
| 943 | 943 | fprintf(hp_file, "%s", (char *)ctr->identity);
|
| 944 | - traceHeapProfSampleString(0, (char *)ctr->identity,
|
|
| 944 | + traceHeapProfSampleString((char *)ctr->identity,
|
|
| 945 | 945 | count * sizeof(W_));
|
| 946 | 946 | break;
|
| 947 | 947 | case HEAP_BY_INFO_TABLE:
|
| 948 | 948 | fprintf(hp_file, "%p", ctr->identity);
|
| 949 | 949 | char str[100];
|
| 950 | 950 | sprintf(str, "%p", ctr->identity);
|
| 951 | - traceHeapProfSampleString(0, str, count * sizeof(W_));
|
|
| 951 | + traceHeapProfSampleString(str, count * sizeof(W_));
|
|
| 952 | 952 | break;
|
| 953 | 953 | #if defined(PROFILING)
|
| 954 | 954 | case HEAP_BY_CCS:
|
| 955 | 955 | fprint_ccs(hp_file, (CostCentreStack *)ctr->identity,
|
| 956 | 956 | RtsFlags.ProfFlags.ccsLength);
|
| 957 | - traceHeapProfSampleCostCentre(0, (CostCentreStack *)ctr->identity,
|
|
| 957 | + traceHeapProfSampleCostCentre((CostCentreStack *)ctr->identity,
|
|
| 958 | 958 | count * sizeof(W_));
|
| 959 | 959 | break;
|
| 960 | 960 | case HEAP_BY_ERA:
|
| 961 | 961 | fprintf(hp_file, "%" FMT_Word, (StgWord)ctr->identity);
|
| 962 | 962 | char str_era[100];
|
| 963 | 963 | sprintf(str_era, "%" FMT_Word, (StgWord)ctr->identity);
|
| 964 | - traceHeapProfSampleString(0, str_era, count * sizeof(W_));
|
|
| 964 | + traceHeapProfSampleString(str_era, count * sizeof(W_));
|
|
| 965 | 965 | break;
|
| 966 | 966 | case HEAP_BY_MOD:
|
| 967 | 967 | case HEAP_BY_DESCR:
|
| 968 | 968 | case HEAP_BY_TYPE:
|
| 969 | 969 | fprintf(hp_file, "%s", (char *)ctr->identity);
|
| 970 | - traceHeapProfSampleString(0, (char *)ctr->identity,
|
|
| 970 | + traceHeapProfSampleString((char *)ctr->identity,
|
|
| 971 | 971 | count * sizeof(W_));
|
| 972 | 972 | break;
|
| 973 | 973 | case HEAP_BY_RETAINER:
|
| ... | ... | @@ -238,7 +238,7 @@ printRetainerSetShort(FILE *f, RetainerSet *rs, W_ total_size, uint32_t max_leng |
| 238 | 238 | }
|
| 239 | 239 | }
|
| 240 | 240 | fputs(tmp, f);
|
| 241 | - traceHeapProfSampleString(0, tmp, total_size);
|
|
| 241 | + traceHeapProfSampleString(tmp, total_size);
|
|
| 242 | 242 | }
|
| 243 | 243 | |
| 244 | 244 | /* -----------------------------------------------------------------------------
|
| ... | ... | @@ -647,10 +647,10 @@ void traceTaskDelete_ (Task *task) |
| 647 | 647 | }
|
| 648 | 648 | }
|
| 649 | 649 | |
| 650 | -void traceHeapProfBegin(StgWord8 profile_id)
|
|
| 650 | +void traceHeapProfBegin(void)
|
|
| 651 | 651 | {
|
| 652 | 652 | if (eventlog_enabled) {
|
| 653 | - postHeapProfBegin(profile_id);
|
|
| 653 | + postHeapProfBegin();
|
|
| 654 | 654 | }
|
| 655 | 655 | }
|
| 656 | 656 | void traceHeapBioProfSampleBegin(StgInt era, StgWord64 time)
|
| ... | ... | @@ -674,11 +674,10 @@ void traceHeapProfSampleEnd(StgInt era) |
| 674 | 674 | }
|
| 675 | 675 | }
|
| 676 | 676 | |
| 677 | -void traceHeapProfSampleString(StgWord8 profile_id,
|
|
| 678 | - const char *label, StgWord residency)
|
|
| 677 | +void traceHeapProfSampleString(const char *label, StgWord residency)
|
|
| 679 | 678 | {
|
| 680 | 679 | if (eventlog_enabled) {
|
| 681 | - postHeapProfSampleString(profile_id, label, residency);
|
|
| 680 | + postHeapProfSampleString(label, residency);
|
|
| 682 | 681 | }
|
| 683 | 682 | }
|
| 684 | 683 | |
| ... | ... | @@ -718,11 +717,10 @@ void traceHeapProfCostCentre(StgWord32 ccID, |
| 718 | 717 | }
|
| 719 | 718 | |
| 720 | 719 | // This one is for .hp samples
|
| 721 | -void traceHeapProfSampleCostCentre(StgWord8 profile_id,
|
|
| 722 | - CostCentreStack *stack, StgWord residency)
|
|
| 720 | +void traceHeapProfSampleCostCentre(CostCentreStack *stack, StgWord residency)
|
|
| 723 | 721 | {
|
| 724 | 722 | if (eventlog_enabled) {
|
| 725 | - postHeapProfSampleCostCentre(profile_id, stack, residency);
|
|
| 723 | + postHeapProfSampleCostCentre(stack, residency);
|
|
| 726 | 724 | }
|
| 727 | 725 | }
|
| 728 | 726 |
| ... | ... | @@ -303,20 +303,18 @@ void traceTaskMigrate_ (Task *task, |
| 303 | 303 | |
| 304 | 304 | void traceTaskDelete_ (Task *task);
|
| 305 | 305 | |
| 306 | -void traceHeapProfBegin(StgWord8 profile_id);
|
|
| 306 | +void traceHeapProfBegin(void);
|
|
| 307 | 307 | void traceHeapProfSampleBegin(StgInt era);
|
| 308 | 308 | void traceHeapBioProfSampleBegin(StgInt era, StgWord64 time);
|
| 309 | 309 | void traceHeapProfSampleEnd(StgInt era);
|
| 310 | -void traceHeapProfSampleString(StgWord8 profile_id,
|
|
| 311 | - const char *label, StgWord residency);
|
|
| 310 | +void traceHeapProfSampleString(const char *label, StgWord residency);
|
|
| 312 | 311 | #if defined(PROFILING)
|
| 313 | 312 | void traceHeapProfCostCentre(StgWord32 ccID,
|
| 314 | 313 | const char *label,
|
| 315 | 314 | const char *module,
|
| 316 | 315 | const char *srcloc,
|
| 317 | 316 | StgBool is_caf);
|
| 318 | -void traceHeapProfSampleCostCentre(StgWord8 profile_id,
|
|
| 319 | - CostCentreStack *stack, StgWord residency);
|
|
| 317 | +void traceHeapProfSampleCostCentre(CostCentreStack *stack, StgWord residency);
|
|
| 320 | 318 | |
| 321 | 319 | void traceProfSampleCostCentre(Capability *cap,
|
| 322 | 320 | CostCentreStack *stack, StgWord ticks);
|
| ... | ... | @@ -369,14 +367,14 @@ void flushTrace(void); |
| 369 | 367 | #define traceTaskCreate_(taskID, cap) /* nothing */
|
| 370 | 368 | #define traceTaskMigrate_(taskID, cap, new_cap) /* nothing */
|
| 371 | 369 | #define traceTaskDelete_(taskID) /* nothing */
|
| 372 | -#define traceHeapProfBegin(profile_id) /* nothing */
|
|
| 370 | +#define traceHeapProfBegin() /* nothing */
|
|
| 373 | 371 | #define traceHeapProfCostCentre(ccID, label, module, srcloc, is_caf) /* nothing */
|
| 374 | 372 | #define traceIPE(ipe) /* nothing */
|
| 375 | 373 | #define traceHeapProfSampleBegin(era) /* nothing */
|
| 376 | 374 | #define traceHeapBioProfSampleBegin(era, time) /* nothing */
|
| 377 | 375 | #define traceHeapProfSampleEnd(era) /* nothing */
|
| 378 | -#define traceHeapProfSampleCostCentre(profile_id, stack, residency) /* nothing */
|
|
| 379 | -#define traceHeapProfSampleString(profile_id, label, residency) /* nothing */
|
|
| 376 | +#define traceHeapProfSampleCostCentre(stack, residency) /* nothing */
|
|
| 377 | +#define traceHeapProfSampleString(label, residency) /* nothing */
|
|
| 380 | 378 | |
| 381 | 379 | #define traceConcMarkBegin() /* nothing */
|
| 382 | 380 | #define traceConcMarkEnd(marked_obj_count) /* nothing */
|
| ... | ... | @@ -95,6 +95,13 @@ bool eventlog_enabled; // protected by state_change_mutex to ensure |
| 95 | 95 | * buffer size, EVENT_LOG_SIZE. We must ensure that no variable-length event
|
| 96 | 96 | * exceeds this limit. For this reason we impose maximum length limits on
|
| 97 | 97 | * fields which may have unbounded values.
|
| 98 | + *
|
|
| 99 | + * Note [Profile ID]
|
|
| 100 | + * ~~~~~~~~~~~~~~~~~
|
|
| 101 | + * The profile ID field of eventlog entries is reserved for future use,
|
|
| 102 | + * with an eye towards supporting multiple parallel heap profiles.
|
|
| 103 | + * In the current RTS, the profile ID is hardcoded to 0.
|
|
| 104 | + *
|
|
| 98 | 105 | */
|
| 99 | 106 | |
| 100 | 107 | static const EventLogWriter *event_log_writer = NULL;
|
| ... | ... | @@ -1219,7 +1226,7 @@ static HeapProfBreakdown getHeapProfBreakdown(void) |
| 1219 | 1226 | }
|
| 1220 | 1227 | }
|
| 1221 | 1228 | |
| 1222 | -void postHeapProfBegin(StgWord8 profile_id)
|
|
| 1229 | +void postHeapProfBegin(void)
|
|
| 1223 | 1230 | {
|
| 1224 | 1231 | ACQUIRE_LOCK(&eventBufMutex);
|
| 1225 | 1232 | PROFILING_FLAGS *flags = &RtsFlags.ProfFlags;
|
| ... | ... | @@ -1244,7 +1251,8 @@ void postHeapProfBegin(StgWord8 profile_id) |
| 1244 | 1251 | CHECK(!ensureRoomForVariableEvent(&eventBuf, len));
|
| 1245 | 1252 | postEventHeader(&eventBuf, EVENT_HEAP_PROF_BEGIN);
|
| 1246 | 1253 | postPayloadSize(&eventBuf, len);
|
| 1247 | - postWord8(&eventBuf, profile_id);
|
|
| 1254 | + // See Note [Profile ID].
|
|
| 1255 | + postWord8(&eventBuf, 0);
|
|
| 1248 | 1256 | postWord64(&eventBuf, TimeToNS(flags->heapProfileInterval));
|
| 1249 | 1257 | postWord32(&eventBuf, getHeapProfBreakdown());
|
| 1250 | 1258 | postStringLen(&eventBuf, flags->modSelector, modSelector_len);
|
| ... | ... | @@ -1286,8 +1294,7 @@ void postHeapProfSampleEnd(StgInt era) |
| 1286 | 1294 | RELEASE_LOCK(&eventBufMutex);
|
| 1287 | 1295 | }
|
| 1288 | 1296 | |
| 1289 | -void postHeapProfSampleString(StgWord8 profile_id,
|
|
| 1290 | - const char *label,
|
|
| 1297 | +void postHeapProfSampleString(const char *label,
|
|
| 1291 | 1298 | StgWord64 residency)
|
| 1292 | 1299 | {
|
| 1293 | 1300 | ACQUIRE_LOCK(&eventBufMutex);
|
| ... | ... | @@ -1296,7 +1303,8 @@ void postHeapProfSampleString(StgWord8 profile_id, |
| 1296 | 1303 | CHECK(!ensureRoomForVariableEvent(&eventBuf, len));
|
| 1297 | 1304 | postEventHeader(&eventBuf, EVENT_HEAP_PROF_SAMPLE_STRING);
|
| 1298 | 1305 | postPayloadSize(&eventBuf, len);
|
| 1299 | - postWord8(&eventBuf, profile_id);
|
|
| 1306 | + // See Note [Profile ID].
|
|
| 1307 | + postWord8(&eventBuf, 0);
|
|
| 1300 | 1308 | postWord64(&eventBuf, residency);
|
| 1301 | 1309 | postStringLen(&eventBuf, label, label_len);
|
| 1302 | 1310 | RELEASE_LOCK(&eventBufMutex);
|
| ... | ... | @@ -1325,8 +1333,7 @@ void postHeapProfCostCentre(StgWord32 ccID, |
| 1325 | 1333 | RELEASE_LOCK(&eventBufMutex);
|
| 1326 | 1334 | }
|
| 1327 | 1335 | |
| 1328 | -void postHeapProfSampleCostCentre(StgWord8 profile_id,
|
|
| 1329 | - CostCentreStack *stack,
|
|
| 1336 | +void postHeapProfSampleCostCentre(CostCentreStack *stack,
|
|
| 1330 | 1337 | StgWord64 residency)
|
| 1331 | 1338 | {
|
| 1332 | 1339 | ACQUIRE_LOCK(&eventBufMutex);
|
| ... | ... | @@ -1340,7 +1347,8 @@ void postHeapProfSampleCostCentre(StgWord8 profile_id, |
| 1340 | 1347 | CHECK(!ensureRoomForVariableEvent(&eventBuf, len));
|
| 1341 | 1348 | postEventHeader(&eventBuf, EVENT_HEAP_PROF_SAMPLE_COST_CENTRE);
|
| 1342 | 1349 | postPayloadSize(&eventBuf, len);
|
| 1343 | - postWord8(&eventBuf, profile_id);
|
|
| 1350 | + // See Note [Profile ID].
|
|
| 1351 | + postWord8(&eventBuf, 0);
|
|
| 1344 | 1352 | postWord64(&eventBuf, residency);
|
| 1345 | 1353 | postWord8(&eventBuf, depth);
|
| 1346 | 1354 | for (ccs = stack;
|
| ... | ... | @@ -163,14 +163,13 @@ void postTaskMigrateEvent (EventTaskId taskId, |
| 163 | 163 | |
| 164 | 164 | void postTaskDeleteEvent (EventTaskId taskId);
|
| 165 | 165 | |
| 166 | -void postHeapProfBegin(StgWord8 profile_id);
|
|
| 166 | +void postHeapProfBegin(void);
|
|
| 167 | 167 | |
| 168 | 168 | void postHeapProfSampleBegin(StgInt era);
|
| 169 | 169 | void postHeapBioProfSampleBegin(StgInt era, StgWord64 time_ns);
|
| 170 | 170 | void postHeapProfSampleEnd(StgInt era);
|
| 171 | 171 | |
| 172 | -void postHeapProfSampleString(StgWord8 profile_id,
|
|
| 173 | - const char *label,
|
|
| 172 | +void postHeapProfSampleString(const char *label,
|
|
| 174 | 173 | StgWord64 residency);
|
| 175 | 174 | |
| 176 | 175 | #if defined(PROFILING)
|
| ... | ... | @@ -180,8 +179,7 @@ void postHeapProfCostCentre(StgWord32 ccID, |
| 180 | 179 | const char *srcloc,
|
| 181 | 180 | StgBool is_caf);
|
| 182 | 181 | |
| 183 | -void postHeapProfSampleCostCentre(StgWord8 profile_id,
|
|
| 184 | - CostCentreStack *stack,
|
|
| 182 | +void postHeapProfSampleCostCentre(CostCentreStack *stack,
|
|
| 185 | 183 | StgWord64 residency);
|
| 186 | 184 | |
| 187 | 185 | void postProfSampleCostCentre(Capability *cap,
|