Skip to content

Conversation

edwintorok
Copy link
Contributor

@edwintorok edwintorok commented Jul 19, 2024

This is an alternative approach, that might be easier to review.

Untested, will need to add some tests next, and then search/replace all the codebase to these new functions in a separate commit that should be a mechanical change.

@edwintorok
Copy link
Contributor Author

Opening as a draft so I remember where to pick up on monday.

@edwintorok edwintorok force-pushed the private/edvint/epoll4 branch from 3f933a0 to d6d3c73 Compare July 22, 2024 13:10
@edwintorok
Copy link
Contributor Author

This now passes a 'dune runtest' locally.

@edwintorok edwintorok force-pushed the private/edvint/epoll4 branch from d6d3c73 to b737acd Compare July 22, 2024 13:12
A drop-in replacement for select that doesn't fail when a file descriptor number is >1024.

This is bad for performance (it makes a lot more syscalls than select),
and performance sensitive callers should instead use `SO_RCVTIMEO/SO_SNDTIMEO` on sockets,
or move the polly instance creation out of loops.

This will also use one additional file descriptor compared to 'select', so it will reach EMFILE sooner.
When replacing `Unix.select` with `Unixext.select` you must also increase resource limits!

Signed-off-by: Edwin Török <[email protected]>
…quivalents

Also add xapi-stdext-unix or xapi-stext-threads as needed to dune.

Signed-off-by: Edwin Török <[email protected]>
@edwintorok edwintorok force-pushed the private/edvint/epoll4 branch 2 times, most recently from ccdb1dc to e9e9422 Compare July 24, 2024 00:06
@edwintorok edwintorok changed the base branch from feature/perf to master July 24, 2024 00:11
@edwintorok
Copy link
Contributor Author

edwintorok commented Jul 24, 2024

This approach looks promising, in fact we have quietly converted most of the core code to epoll years ago.

XAPI has been using epoll for its main HTTP handler since 2022 5187883.
Xenopsd has been using epoll internally since 2017 8c77c5c
And it has been using the Polly implementation since 2020 0610645.

So we only really need to optimize one caller, the one in buf_io, and I cherry-picked the commit that converts that from 'select' to 'setsockopt' timeouts.

What remains to be done here before undrafting is:

  • write a unit test for Unixext.select, by adding it to the framework that already exists in unixext_test.
  • ability to run the stdext epoll quickcheck tests in Dom0, e.g. by adding them to 'quicktest' (which automatically runs in Ring3 BVT)

It doesn't require the Clock.Timer changes anymore (although doing those would still be useful, but we can do that in a separate PR)

This new approach looks promising, it is a lot smaller:

25 files changed, 278 insertions(+), 26 deletions(-)

@edwintorok
Copy link
Contributor Author

continued in #5911

@edwintorok edwintorok closed this Aug 5, 2024
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.

1 participant