mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
* core: plumbing to support numa aware scheduling * core: apply node resources compatibility upon fsm rstore Handle the case where an upgraded server dequeus an evaluation before a client triggers a new fingerprint - which would be needed to cause the compatibility fix to run. By running the compat fix on restore the server will immediately have the compatible pseudo topology to use. * lint: learn how to spell pseudo
34 lines
976 B
Go
34 lines
976 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
//go:build !ent
|
|
|
|
package scheduler
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/client/lib/idset"
|
|
"github.com/hashicorp/nomad/client/lib/numalib"
|
|
"github.com/hashicorp/nomad/client/lib/numalib/hw"
|
|
"github.com/hashicorp/nomad/helper"
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
)
|
|
|
|
type coreSelector struct {
|
|
topology *numalib.Topology
|
|
availableCores *idset.Set[hw.CoreID]
|
|
}
|
|
|
|
// Select returns a set of CoreIDs that satisfy the requested core reservations,
|
|
// as well as the amount of CPU bandwidth represented by those specific cores.
|
|
//
|
|
// NUMA preference is available in ent only.
|
|
func (cs *coreSelector) Select(ask *structs.Resources) ([]uint16, hw.MHz) {
|
|
cores := cs.availableCores.Slice()[0:ask.Cores]
|
|
mhz := hw.MHz(0)
|
|
for _, core := range cores {
|
|
mhz += cs.topology.Cores[core].MHz()
|
|
}
|
|
ids := helper.ConvertSlice(cores, func(id hw.CoreID) uint16 { return uint16(id) })
|
|
return ids, mhz
|
|
}
|