Skip to content

Commit fc1d96f

Browse files
committed
CP-53335, topology: Avoid duplicates in candidate NUMA nodes
It's unclear why the candidates with single nodes where always added, since the algorithm that generates all the subsets already includes these. Signed-off-by: Pau Ruiz Safont <pau.ruizsafont@cloud.com>
1 parent 75e4c31 commit fc1d96f

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

ocaml/xenopsd/lib/topology.ml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ let seq_sort ~cmp s =
121121
let a = Array.of_seq s in
122122
Array.fast_sort cmp a ; Array.to_seq a
123123

124-
(** [seq_append a b] is the sequence [a] followed by [b] *)
125-
let seq_append (a : 'a Seq.t) (b : 'a Seq.t) =
126-
let rec next v () =
127-
match v () with Seq.Nil -> b () | Seq.Cons (x, xs) -> Seq.Cons (x, next xs)
128-
in
129-
next a
130-
131124
module NUMA = struct
132125
type node = Node of int
133126

@@ -194,25 +187,19 @@ module NUMA = struct
194187
None
195188
)
196189
in
197-
let single_nodes =
198-
valid_nodes
199-
|> Seq.map (fun i ->
200-
let self_distance = d.(i).(i) in
201-
(distance_to_candidate self_distance, Seq.return i)
202-
)
203-
in
204190
let numa_nodes = Array.length d in
205191
let nodes =
206192
if numa_nodes > 16 then
207-
(* try just the single nodes, and give up (use all nodes otherwise) to
208-
avoid exponential running time. We could do better here, e.g. by
193+
(* Avoid generating too many candidates because of the exponential
194+
running time. We could do better here, e.g. by
209195
reducing the matrix *)
210-
single_nodes
211-
else
212196
valid_nodes
213-
|> seq_all_subsets
214-
|> Seq.filter_map (node_distances d)
215-
|> seq_append single_nodes
197+
|> Seq.map (fun i ->
198+
let self = d.(i).(i) in
199+
(distance_to_candidate self, Seq.return i)
200+
)
201+
else
202+
valid_nodes |> seq_all_subsets |> Seq.filter_map (node_distances d)
216203
in
217204
nodes
218205
|> seq_sort ~cmp:dist_cmp

ocaml/xenopsd/test/test_topology.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,14 @@ let allocate_tests =
281281
let distances_tests =
282282
let specs =
283283
[
284-
( "Last node is unreachable"
285-
, Distances.unreachable_last
286-
, Some [(10., [0]); (10., [0])]
287-
)
284+
("Last node is unreachable", Distances.unreachable_last, Some [(10., [0])])
288285
; ( "Node in the middle is unreachable"
289286
, Distances.unreachable_middle
290-
, Some [(10., [0]); (10., [2]); (10., [0]); (10., [2]); (15., [0; 2])]
287+
, Some [(10., [0]); (10., [2]); (15., [0; 2])]
291288
)
292289
; ( "The first two nodes are unreachable"
293290
, Distances.unreachable_two
294-
, Some [(10., [2]); (10., [2])]
291+
, Some [(10., [2])]
295292
)
296293
; ("All nodes are unreachable", Distances.none_reachable, None)
297294
]

0 commit comments

Comments
 (0)