Skip to content

Commit

Permalink
MQE: fix incorrect peak memory consumption value reported for benchma…
Browse files Browse the repository at this point in the history
…rks run on Linux (#10031)
  • Loading branch information
charleskorn authored Nov 29, 2024
1 parent fb07ed6 commit b14cac1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tools/benchmark-query-engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"slices"
"strings"
"syscall"
Expand Down Expand Up @@ -339,11 +340,22 @@ func (a *app) runTestCase(name string, printBenchmarkHeader bool) error {
}
} else if isBenchmarkLine {
fmt.Print(l)
fmt.Printf(" %v B\n", usage.Maxrss)
fmt.Printf(" %v B\n", maxRSSInBytes(usage))
} else if !isPassLine {
fmt.Println(l)
}
}

return nil
}

func maxRSSInBytes(usage *syscall.Rusage) int64 {
switch runtime.GOOS {
case "Linux":
return usage.Maxrss * 1024 // Maxrss is returned in kilobytes on Linux.
case "Darwin":
return usage.Maxrss // Maxrss is already in bytes on macOS.
default:
panic(fmt.Sprintf("unknown GOOS '%v'", runtime.GOOS))
}
}

0 comments on commit b14cac1

Please sign in to comment.