Skip to content

Merge performance improvements#6987

Draft
edwintorok wants to merge 11 commits intomasterfrom
feature/perf-edvint
Draft

Merge performance improvements#6987
edwintorok wants to merge 11 commits intomasterfrom
feature/perf-edvint

Conversation

@edwintorok
Copy link
Copy Markdown
Member

@edwintorok edwintorok commented Mar 31, 2026

Draft, waiting for testing and PR reviews to complete.

Depends on:
#6974
#6971

Also would be good to have an updated ocaml-rpc for the JSONRPC fixes in xs-opam.

PRs for ocaml-rpc optimizations:
mirage/ocaml-rpc#194
mirage/ocaml-rpc#193
mirage/ocaml-rpc#192
mirage/ocaml-rpc#184

The optimizations are not strictly required, but the first PR about fixing 4.14 build is, otherwise we can't take the new version into xs-opam.

edwintorok and others added 10 commits March 13, 2026 16:05
Also introduce a batching delay on all Event.{from,next} calls, except
Event.from calls for tasks. This should help batch up multiple events from
field updates.

There are no extra delays for tasks, because these typically aren't immediately ready,
and when they are we want to immediately find out about it.

This is part of the "feature flag" that turns on the feature
(previously you could've manually edited xapi.conf to make these changes.)

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
This will enable short-circuiting internal API calls.

When the FD is missing mark the call as Internal.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Edwin Török <edwin.torok@citrix.com>
…forward the API call directly like we do with the CLI for calls to the coordinator when we are the coordinator

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
This has been benchmarked as part of an ocaml-rpc change.
The tail-modulo-cons (TMC) version is the fastest:
```
map/List.map (ns):
 { monotonic-clock per run = 1367.762962 (confidence: 1427.389585 to 1335.537246);
   r² = Some 0.885423 }
map/List.rev_map + List.rev (ns):
 { monotonic-clock per run = 758.812720 (confidence: 763.894690 to 753.944851);
   r² = Some 0.992898 }
map/TMC map (ns):
 { monotonic-clock per run = 584.662582 (confidence: 589.477056 to 579.975956);
   r² = Some 0.991475 }
```

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
Avoid allocating a string for each char.
The next step will be to switch to upstream Xmlm for output too
(it is currently only used for input). 
That one has a more optimized escaping function, that can efficiently skip over chars
that don't need escaping.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Edwin Török <edwin.torok@citrix.com>
Similar to the ones I've done in `ocaml-rpc`.

Ideally we'd drop the duplicate implementation from here, and use the
one from `ocaml-rpc` directly, but that is a bigger and riskier change
(in case we had some custom hacks in our XML format that some tool ended
up relying on).

The biggest improvement here is from not calling `String.make 1 c` on
each character anymore.
Targeting a feature branch, where it can all be merged to master once
testing is complete.
Copy link
Copy Markdown
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

I've seen this before.

@lindig lindig requested a review from psafont March 31, 2026 13:13
Also introduce a batching delay on all Event.{from,next} calls, except
Event.from calls for tasks. This should help batch up multiple events
from field updates.

There are no extra delays for tasks, because these typically aren't
immediately ready, and when they are we want to immediately find out
about it.

This is part of the "feature flag" that turns on the feature (previously
you could've manually edited xapi.conf to make these changes.)
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.

2 participants