Skip to content

Commit 81561fd

Browse files
committed
feat: add mem/gc stats to progress reporter
1 parent 07e5524 commit 81561fd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pkg/exporter/exporter.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ func (e *Exporter) ProgressReporter(ctx context.Context, totalTiles int) {
208208
defer ticker.Stop()
209209

210210
start := time.Now()
211+
var m runtime.MemStats
212+
var lastGCPauseNs uint64
211213

212214
for {
213215
select {
@@ -224,7 +226,22 @@ func (e *Exporter) ProgressReporter(ctx context.Context, totalTiles int) {
224226
remaining = totalTime - elapsed
225227
}
226228

227-
fmt.Printf("progress: %.2f%% (%s elapsed, %s remaining)\n", progress, elapsed, remaining)
229+
runtime.ReadMemStats(&m)
230+
if m.NumGC > 0 {
231+
lastGCPauseNs = m.PauseNs[(m.NumGC+255)%256]
232+
} else {
233+
lastGCPauseNs = 0
234+
}
235+
fmt.Printf("progress: %.2f%% (%s elapsed, %s remaining) | alloc = %vMiB, total = %vMiB, numgc = %v, gcpause = %.2fs, last = %dms\n",
236+
progress,
237+
elapsed,
238+
remaining,
239+
m.Alloc/1024/1024,
240+
m.TotalAlloc/1024/1024,
241+
m.NumGC,
242+
time.Duration(m.PauseTotalNs).Seconds(),
243+
int(time.Duration(lastGCPauseNs).Milliseconds()),
244+
)
228245

229246
if current >= totalTiles {
230247
return

0 commit comments

Comments
 (0)