Skip to content

Commit

Permalink
without hax to speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Feb 3, 2023
1 parent ea2d4ac commit beba4cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
23 changes: 6 additions & 17 deletions resource3/plugins/cpumem/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math"
"strconv"

"github.com/alphadose/haxmap"
"github.com/cockroachdb/errors"
"github.com/mitchellh/mapstructure"
enginetypes "github.com/projecteru2/core/engine/types"
Expand Down Expand Up @@ -341,25 +340,15 @@ func (p Plugin) doGetNodesResourceInfo(ctx context.Context, nodenames []string)
return nil, err
}

tmp := haxmap.New[string, *cpumemtypes.NodeResourceInfo]()
result := map[string]*cpumemtypes.NodeResourceInfo{}

for _, resp := range resps {
resp := resp
go func() {
r := &cpumemtypes.NodeResourceInfo{}
if err := json.Unmarshal(resp.Value, r); err != nil {
log.WithFunc("resource.cpumem.doGetNodesResourceInfo").Error(ctx, err)
return
}
nodename := utils.Tail(string(resp.Key))
tmp.Set(nodename, r)
}()
}
tmp.ForEach(func(k string, v *cpumemtypes.NodeResourceInfo) bool {
result[k] = v
return true
})
r := &cpumemtypes.NodeResourceInfo{}
if err := json.Unmarshal(resp.Value, r); err != nil {
return nil, err
}
result[utils.Tail(string(resp.Key))] = r
}
return result, nil
}

Expand Down
2 changes: 1 addition & 1 deletion resource3/plugins/cpumem/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func BenchmarkGetNodesCapacity(b *testing.B) {
t := &testing.T{}
ctx := context.Background()
cm := initCPUMEM(ctx, t)
nodes := generateNodes(ctx, t, cm, 10000, 24, 128*units.GB, 100, 0)
nodes := generateNodes(ctx, t, cm, 1000, 24, 128*units.GB, 100, 0)
req := &plugintypes.WorkloadResourceRequest{
"cpu-bind": true,
"cpu-request": 1.3,
Expand Down

0 comments on commit beba4cd

Please sign in to comment.