|
1 | 1 | // This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
3 | 3 | #include "gc.h"
|
| 4 | +#include "julia.h" |
4 | 5 | #include <inttypes.h>
|
| 6 | +#include <stddef.h> |
| 7 | +#include <stdint.h> |
5 | 8 | #include <stdio.h>
|
6 | 9 |
|
7 | 10 | // re-include assert.h without NDEBUG,
|
@@ -1216,15 +1219,30 @@ JL_DLLEXPORT void jl_enable_gc_logging(int enable) {
|
1216 | 1219 | gc_logging_enabled = enable;
|
1217 | 1220 | }
|
1218 | 1221 |
|
1219 |
| -void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect) JL_NOTSAFEPOINT { |
| 1222 | +void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect, int64_t live_bytes) JL_NOTSAFEPOINT { |
1220 | 1223 | if (!gc_logging_enabled) {
|
1221 | 1224 | return;
|
1222 | 1225 | }
|
1223 | 1226 | jl_safe_printf("GC: pause %.2fms. collected %fMB. %s %s\n",
|
1224 |
| - pause/1e6, freed/1e6, |
| 1227 | + pause/1e6, freed/(double)(1<<20), |
1225 | 1228 | full ? "full" : "incr",
|
1226 | 1229 | recollect ? "recollect" : ""
|
1227 | 1230 | );
|
| 1231 | + |
| 1232 | + jl_safe_printf("Heap stats: bytes_mapped %.2f MB, bytes_allocd %.2f MB\nbytes_freed %.2f MB, bytes_mallocd %.1f, malloc_bytes_freed %.2f MB\npages_perm_allocd %zu, heap_size %.2f MB, heap_target %.2f MB, live_bytes %.2f MB\n", |
| 1233 | + jl_atomic_load_relaxed(&gc_heap_stats.bytes_mapped)/(double)(1<<20), |
| 1234 | + jl_atomic_load_relaxed(&gc_heap_stats.bytes_allocd)/(double)(1<<20), |
| 1235 | + jl_atomic_load_relaxed(&gc_heap_stats.bytes_freed)/(double)(1<<20), |
| 1236 | + jl_atomic_load_relaxed(&gc_heap_stats.bytes_mallocd)/(double)(1<<20), |
| 1237 | + jl_atomic_load_relaxed(&gc_heap_stats.malloc_bytes_freed)/(double)(1<<20), |
| 1238 | + jl_atomic_load_relaxed(&gc_heap_stats.pages_perm_allocd), |
| 1239 | + jl_atomic_load_relaxed(&gc_heap_stats.heap_size)/(double)(1<<20), |
| 1240 | + jl_atomic_load_relaxed(&gc_heap_stats.heap_target)/(double)(1<<20), |
| 1241 | + live_bytes/(double)(1<<20) |
| 1242 | + ); |
| 1243 | + double bytes_mapped = (jl_atomic_load_relaxed(&gc_heap_stats.bytes_resident) + jl_atomic_load_relaxed(&gc_heap_stats.bytes_mallocd) - jl_atomic_load_relaxed(&gc_heap_stats.malloc_bytes_freed))/(double)(1<<20); |
| 1244 | + jl_safe_printf("Fragmentation %f, mapped_bytes %.2f MB\n", (double)live_bytes/(double)jl_atomic_load_relaxed(&gc_heap_stats.heap_size), bytes_mapped); |
| 1245 | + // Should fragmentation use bytes_resident instead of heap_size? |
1228 | 1246 | }
|
1229 | 1247 |
|
1230 | 1248 | #ifdef __cplusplus
|
|
0 commit comments