Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DiagnosticServer runtime TCP support. #48154

Merged

Conversation

lateralusX
Copy link
Member

@lateralusX lateralusX commented Feb 11, 2021

Restructuring of existing DiagnosticServer PAL code into following:

Win32 named pipe support for local IPC is renamed to ds-ipc-pal-namedpipe.h|c
Unix domain socket support for local IPC is part of more generic socket support ds-ipc-pal-socket.h|c

By default all builds and run as before, win32 uses named pipe for local IPC and none Windows uses Unix domain sockets.

This PR extends support in ds-ipc-pal-socket.* to also support TCP (IPv4/IPv6) transports cross platform, meaning that its possible to configure and compile DiagnosticServer using TCP instead of NamedPipe/Unix Domain Sockets for both listener and connect scenarios. TCP support will be needed in order to support EventPipe on remote targets like mobile, but then most likely only supporting the connect scenario (no listener support) and only for builds used during development/testing and profiling work, but all is completely configurable.

PR adds a couple of build config flags that could be used:

FEATURE_PERFTRACING_PAL_TCP

Enables TCP/IP support in diagnostics server on all platforms, instead of default named pipe/unix domain socket support.

FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS

Disables ability for diagnostic server to connect against remote ports.

FEATURE_PERFTRACING_DISABLE_LISTEN_PORTS

Disables ability for diagnostic server to listen on local ports.

By default none of the above config flags are used by this PR, but for some Mono runtime workloads we will need TCP/IP and connect ports (listen ports can be disabled).

@lateralusX lateralusX force-pushed the lateralusX/add-eventpipe-tcp-support branch 3 times, most recently from 130296b to 2c7191c Compare February 12, 2021 08:17
@ghost
Copy link

ghost commented Feb 12, 2021

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Restructuring of existing DiagnosticServer PAL code into following:

Win32 named pipe support for local IPC is renamed to ds-ipc-pal-namedpipe.h|c
Unix domain socket support for local IPC is part of more generic socket support ds-ipc-pal-socket.h|c

By default all builds and run as before, win32 uses named pipe for local IPC and none Windows uses Unix domain sockets.

This PR extends support in ds-ipc-pal-socket.* to also support TCP (IPv4/IPv6) transports cross platform, meaning that its possible to configure and compile DiagnosticServer using TCP instead of NamedPipe/Unix Domain Sockets for both listener and connect scenarios. TCP support will be needed in order to support EventPipe on remote targets like mobile, but then most likely only supporting the connect scenario (no listener support) and only for builds used during development/testing and profiling work, but all is completely configurable.

Author: lateralusX
Assignees: -
Labels:

area-Diagnostics-coreclr

Milestone: -

@lateralusX
Copy link
Member Author

/cc @josalem

Base automatically changed from master to main March 1, 2021 09:07
@lateralusX lateralusX force-pushed the lateralusX/add-eventpipe-tcp-support branch from 2c7191c to 21e5211 Compare March 3, 2021 17:26
@lateralusX lateralusX changed the title WIP: Add DiagnosticServer runtime TCP support. Add DiagnosticServer runtime TCP support. Mar 4, 2021
@lateralusX lateralusX marked this pull request as ready for review March 4, 2021 17:37
@lateralusX lateralusX force-pushed the lateralusX/add-eventpipe-tcp-support branch from 998f795 to 04ff29c Compare March 5, 2021 13:57
Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

  1. Mono bits look ok (although the lower priority we can make non-actionable log messages the better)
  2. I'm concerned by the apparent lack of EINTR handling around I/O operations in particular and syscalls in general. Maybe I just didn't grep for the right thing.

src/mono/mono/eventpipe/ds-rt-mono.h Show resolved Hide resolved
src/native/eventpipe/ds-dump-protocol.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc-pal-socket.c Outdated Show resolved Hide resolved
src/native/eventpipe/ds-ipc-pal-socket.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc-pal-socket.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc-pal-socket.c Show resolved Hide resolved
@lateralusX
Copy link
Member Author

  1. Mono bits look ok (although the lower priority we can make non-actionable log messages the better)
  2. I'm concerned by the apparent lack of EINTR handling around I/O operations in particular and syscalls in general. Maybe I just didn't grep for the right thing.

Regarding EINTR, the original Unix Domain Socket implementation didn't have this either, so that carried over into this implementation. A lot of the calls will be retried at some point, but agree that we should add checks and retry just to be clear. It will be easy done now as well since all send/recv/poll/connect operations are part of their own methods, @josalem, any thoughts?

@lateralusX
Copy link
Member Author

Looking into adding EINTR handling into this PR.

@lateralusX
Copy link
Member Author

@lambdageek Added retry logic for syscalls documented to return EINTR.

Copy link
Contributor

@josalem josalem left a comment

Choose a reason for hiding this comment

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

The feature flags you have included map out to the following table of possibilities:

✅ NamedPipe+UDS ❌ TCP <-- default
❌ NamedPipe+UDS ✅ TCP
❌ NamedPipe+UDS ❌ TCP

correct?

src/mono/mono/eventpipe/CMakeLists.txt Outdated Show resolved Hide resolved
src/native/eventpipe/ds-dump-protocol.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc-pal-socket.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc.c Show resolved Hide resolved
src/native/eventpipe/ds-ipc.c Show resolved Hide resolved
@lateralusX
Copy link
Member Author

The feature flags you have included map out to the following table of possibilities:

✅ NamedPipe+UDS ❌ TCP <-- default
❌ NamedPipe+UDS ✅ TCP
❌ NamedPipe+UDS ❌ TCP
correct?

Yes, so right now we can only have NamedPipe+UDS support or TCP, not possible to combine them. Default is what we have today, NamedPipe +UDS. In order switch to TCP, you need to define CMake build flag, FEATURE_PERFTRACING_PAL_TCP.

Copy link
Contributor

@josalem josalem left a comment

Choose a reason for hiding this comment

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

LGTM 👍
CC @noahfalk @sywhang

Newline added by Mono logging API, so needed to make source free of newline.
Since newline is needed by CoreClr, add it as part of DS logging macro's.
Move verbose logging into debug log level.

Reduce warnings in connection time out scenario, could be very frequent
for TCP/IP where no endpoint is up and listening.

Restored error handling in ds_ipc_stream_factory_get_next_available_stream.
@lateralusX lateralusX force-pushed the lateralusX/add-eventpipe-tcp-support branch from 9a7d95f to aea1c2f Compare March 19, 2021 07:57
@lateralusX lateralusX merged commit ca1a5cf into dotnet:main Mar 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 22, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants