Skip to content

Commit

Permalink
TAS: allow to dump the usage of domains for TAS ResourceFlavors
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikkuzn committed Feb 26, 2025
1 parent 68fb531 commit 136b749
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/cache/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func (s *Snapshot) Log(log logr.Logger) {
"usage", cohort.ResourceNode.Usage,
)
}

// Dump TAS snapshots if the feature is enabled
if features.Enabled(features.TopologyAwareScheduling) {
for cqName, cq := range s.ClusterQueues {
for tasFlavor, tasSnapshot := range cq.TASFlavors {
log.Info("TAS Snapshot Free Capacity",
"clusterQueue", cqName,
"resourceFlavor", tasFlavor,
"freeCapacityPerDomain", tasSnapshot.FreeCapacityPerDomain(),
)
}
}
}
}

func (c *Cache) Snapshot(ctx context.Context) (*Snapshot, error) {
Expand Down
16 changes: 16 additions & 0 deletions pkg/cache/tas_flavor_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ func (s *TASFlavorSnapshot) removeTASUsage(domainID utiltas.TopologyDomainID, us
s.leaves[domainID].tasUsage.Sub(usage)
}

func (s *TASFlavorSnapshot) FreeCapacityPerDomain() map[string]int {
freeCapacityPerDomain := make(map[string]int)

for domainID, leaf := range s.leaves {
// Calculate the total free capacity for the domain
totalFreeCapacity := 0
for _, quantity := range leaf.freeCapacity {
totalFreeCapacity += int(quantity)
}

freeCapacityPerDomain[string(domainID)] = totalFreeCapacity
}

return freeCapacityPerDomain
}

type TASPodSetRequests struct {
PodSet *kueue.PodSet
SinglePodRequests resources.Requests
Expand Down

0 comments on commit 136b749

Please sign in to comment.