On Fri, 31 Jan 2025 23:23:36 GMT, Alex Menkov <amen...@openjdk.org> wrote:
> The fix implements streaming output support for attach protocol. > See JBS issue for evaluation, summary of the changes in the 1st comment. > Testing: tier1..4,hs-tier5-svc The changes: Attach API protocol: - attach operation options are added for ATTACH_API_V2 requests. The options are passed as part of command name; old clients old clients enquere command without options, new client adds options only if target VM support them, so there is no need to bump attach api version; - "getversion" command supports new "options" argument. with this argument VM reports supported options. The only supported option for now is "streaming" which allows client to control streaming/buffered output mode. AttachListener: - implemented attachStream class to support both streaming and buffered output; - all attach command handler are updated to use attachStream instead of bufferedStream and start streaming (if enabled) after parsing command arguments; - default streaming mode is controlled by "jdk.attach.vm.streaming" system properties; this value is used when clients does not specify "streaming" option in the request (for example when tools from older releases attach to the current VM). For safety now default value is "false" (i.e. buffered output). The plan is to make the default "true" later; - platform implementations (windows/posix) updated accordingly shared code changes; DCmd framework: - added a way to start streaming output after command/argument parsing, but before executing the command; Client side: - added option support; - added system property "jdk.attach.allowStreamingOutput" to set streaming mode; For now default value is "false" (i.e. to turn on streaming mode user need something like "JAVA_TOOL_OPTIONS=-Djdk.attach.allowStreamingOutput=true jcmd") The plan is to make the default "true" after fixing tests which fail with streaming output (or maybe add command line option for jcmd and other tools). Test CodeHeapAnalyticsParams.java - 'Compiler.CodeHeap_Analytics' jcmd command is the only command which thrown AttachOperationFailedException exception if argument is out of range (and this causes jcmd exits with exit code 1). All other jcmd commands just writes exception message in the output. Now 'Compiler.CodeHeap_Analytics' works like other commands, so the test is updated to expect exception message. ------------- PR Comment: https://git.openjdk.org/jdk/pull/23405#issuecomment-2628559151