Skip to content

Conversation

@lindig
Copy link
Contributor

@lindig lindig commented Nov 7, 2025

The missing bits: when xenopsd reports a new VM state; update its numa state in xapi accordingly.

Signed-off-by: Christian Lindig <[email protected]>
@lindig lindig requested review from mg12 and robhoes November 7, 2025 14:27
; numa_nodes= numa.Xenctrlext.DomainNuma.nodes
; numa_node_memory=
Array.fold_left
(fun (i, assoc) mem -> (i + 1, (i, mem) :: assoc))
Copy link
Contributor

@edwintorok edwintorok Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Array.mapi simplify this code? (followed by Array.to_list)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Let's mapi do the work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using Array.mapi means a new array is allocated, do we want that?

One way to avoid it would be:

                numa.Xenctrlext.DomainNuma.memory
                |> Array.to_seq
                |> Seq.mapi (fun i mem -> (i, mem))
                |> List.of_seq

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cheaper? I don't understand the cost of Seq well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seq is a lazy structure, and the transformations only get executed for building the end result, so instead of creating a new array and a new list, this should create a new list only (and the closures for doing the transformation for each value)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect the intermediary closures will end up using more space than creating a fresh array: the List.of_seq amounts to consecutively forcing the sequence (applying the closures that arise from the partial application of the next array index). The previous closures will probably be around until the next minor sweep.

I'm actually really fond of the original version of the code. It avoids the space problem entirely.

Signed-off-by: Christian Lindig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants