JDK-8225312 : Deprecate -XX:FlightRecorder Option
  • Type: CSR
  • Component: hotspot
  • Sub-Component: jfr
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-06-04
  • Updated: 2019-06-06
  • Resolved: 2019-06-06
Related Reports
CSR :  
Description
Summary
-------

Deprecate -XX:FlightRecorder option as it is no longer needed.

Problem
-------

Before JDK 8u40, HotSpot needed to allocate JFR thread buffers when a thread was created. 

To ensure that recordings could be started on an already running JVM, using JMX or jcmd, the option -XX:FlightRecorder was added. If set to true, every new thread would get a 5 KB buffer, regardless if a recording was started or not.

In JDK 8u40 that restriction was lifted and a thread buffer could be added to an already running thread. That effectively made -XX:+FlightRecorder a no-op.

Even though the flag has been useless for 4.5 years, it is still widely used and gives the impression that it is more complicated to use JFR than it really is. 

Solution
-------
Deprecate the flag.

It should be noted that -XX:-FlightRecorder could be used to prevent a user from starting JFR and make the jdk.jfr.FlightRecorder::isAvailable() method return false. This would still be the case after deprecation, but if the flag were to be removed later, it would change the behaviour of that method, which is probably OK.



Specification
-------------

    diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
    --- a/src/hotspot/share/runtime/arguments.cpp
    +++ b/src/hotspot/share/runtime/arguments.cpp
    @@ -537,7 +537,8 @@
       { "AllowJNIEnvProxy",             JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
       { "ThreadLocalHandshakes",        JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
       { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
    -
    +  { "FlightRecorder",               JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
    +
       // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
       { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
       { "CreateMinidumpOnCrash",        JDK_Version::jdk(9),  JDK_Version::undefined(), JDK_Version::undefined() },
    diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
    --- a/src/hotspot/share/runtime/globals.hpp
    +++ b/src/hotspot/share/runtime/globals.hpp

    @@ -2549,7 +2550,7 @@
               "leverage profiling for table/lookup switch")                     \
                                                                                 \
       JFR_ONLY(product(bool, FlightRecorder, false,                             \
    -          "Enable Flight Recorder"))                                        \
    +          "(Deprecated) Enable Flight Recorder"))                                        \
                                                                                 \
       JFR_ONLY(product(ccstr, FlightRecorderOptions, NULL,                      \
               "Flight Recorder options"))                                       \

Comments
Moving to Approved.
06-06-2019

Thanks Erik. I have reviewed this. Please move to Finalized.
06-06-2019

[~dholmes] Yes, you must ask for a recording to be started. -XX:FlightRecorder will prevent a user from starting it, on command line or at runtime. Given that JFR has been open sourced and there is little need to check if FlightRecorder is available, I don't think there is a good use case for the flag.
05-06-2019

Fixed typo: icmd -> jcmd Aside: this edit should not be present: @@ -1,5 +1,6 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, + Oracle and/or its affiliates. All rights reserved. [~egahlin] Can you clarify the behaviour of `-XX:-FlightRecorder` please. My understanding is that JFR is disabled unless you explicitly ask for a recording to start. So `-XX:-FlightRecorder` is not necessary to disable JFR as such, but if it is set it will prevent JFR from being dynamically started during execution of the VM. Is that correct? If so it is unclear to me whether the need for this dynamic-disabling capability is something that end users actively use and want?
05-06-2019

Moving to Provisional.
05-06-2019