Skip to content

Commit

Permalink
Performance test time reduction
Browse files Browse the repository at this point in the history
1) Use 32MiB per core for bandwidth
2) Use 16MiB for latency
  • Loading branch information
HJ-Fan committed Apr 15, 2024
1 parent b506632 commit 77a92d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cmd/cxl-util/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/klog/v2"
)

var Version = "1.0.0"
var Version = "1.3.2"

// This variable is filled in during the linker step - -ldflags "-X main.buildTime=`date -u '+%Y-%m-%dT%H:%M:%S'`"
var buildTime = ""
Expand Down Expand Up @@ -168,6 +168,11 @@ func main() {

if dev.Cdat != nil {
dev.Cdat.PrintAllCDAT()

devPerf := dev.Cdat.Get_CDAT_DSLBIS_performance()
fmt.Print("\nCDAT DSLBIS reported performance:")
fmt.Println("\nCDAT DSLBIS reported performance:", devPerf)

} else {
fmt.Printf("\n\nCDAT is not available on dev: %s\n", settings.PCIE)
}
Expand Down Expand Up @@ -212,11 +217,6 @@ func main() {

}

if dev.Cdat != nil {
devPerf := dev.Cdat.Get_CDAT_DSLBIS_performance()
fmt.Print("\nCDAT DSLBIS reported performance:")
fmt.Println("\nCDAT DSLBIS reported performance:", devPerf)
}
devBW, err := dev.MeasureBandwidth()
if err == nil {
fmt.Printf("\nMeasured Bandwidth: %.2f GiB/s\n", devBW)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Seagate/cxl-lib

go 1.20
go 1.22.1

require k8s.io/klog/v2 v2.100.1

Expand Down
12 changes: 7 additions & 5 deletions pkg/cxl/cxl-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func (c *CxlDev) MeasureLatency() (uint64, error) {
var diff time.Duration

startAddr := c.GetMemoryBaseAddr()
testSize := 128 << 20 // 128MiB should be enough for latency measurement while not taking too long
testSize := 16 << 20 // Limit to 16MiB test size

mem_file, err := os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, 0)
if err != nil {
Expand Down Expand Up @@ -572,7 +572,7 @@ func (c *CxlDev) MeasureLatency() (uint64, error) {

lat := uint64(diff.Nanoseconds() / int64(testSize>>3))

klog.V(DBG_LVL_BASIC).Infof("cxlDev.MeasureBandwidth: totalSize %d MiB, time %d ns", testSize>>20, diff.Nanoseconds())
klog.V(DBG_LVL_BASIC).Infof("cxlDev.MeasureLatency: totalSize %d MiB, time %d ns", testSize>>20, diff.Nanoseconds())
klog.V(DBG_LVL_BASIC).Infof("Average memory latency: %d ns\n", lat)

return lat, nil
Expand Down Expand Up @@ -603,8 +603,11 @@ func (c *CxlDev) MeasureBandwidth() (float64, error) {
var start, end time.Time
var diff time.Duration

startAddr := c.GetMemoryBaseAddr()
totalSize := int(c.GetMemorySize())
numCPU := runtime.NumCPU()

// Measure 1GiB from the middle of the memory
startAddr := c.GetMemoryBaseAddr() + c.GetMemorySize()/2
totalSize := min(int(c.GetMemorySize()), numCPU<<25) // 32MiB per core

mem_file, err := os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, 0)
if err != nil {
Expand All @@ -618,7 +621,6 @@ func (c *CxlDev) MeasureBandwidth() (float64, error) {
}

mRange := (*memRange)(unsafe.Pointer(&mmap))
numCPU := runtime.NumCPU()
ch := make(chan int, numCPU) // Buffering optional but sensible.

// fill the test area
Expand Down

0 comments on commit 77a92d4

Please sign in to comment.