Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8290464

Optimize ResourceArea zapping on ResourceMark release

XMLWordPrintable

    • b08

        Seen this in profile for a long-running test:

        $ CONF=linux-x86_64-server-fastdebug make test TEST=java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java

        The hotpath is in the method below, where we have `ResourceMark` that is needed for possible call to `name_and_sig_as_C_string()`:

        ```
        bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
           ...
        #ifdef ASSERT
          ResourceMark rm;
          bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
          if (class_access_flags.is_interface()) {
              assert(is_nonv == is_static() || is_nonv == is_private(),
                     "nonvirtual unexpected for non-static, non-private: %s",
                     name_and_sig_as_C_string());
          }
        #endif
          ...
        }
        ```

        ...but we end up doing `ResourceMark` destruction all the time on all paths, which includes `ZapResourceArea` code, which zaps the entirety of *untouched* `ResourceArea` chunk.

        While we can rewrite the code and use `ResourceMark` closer to the `assert`, I think optimizing the `ResourceArea` zapping itself would be beneficial for the entire Hotspot. Both moving the `ResourceMark` and generically optimizing the `ResourceArea` zapping yields the similar improvements on this test:

        ```
        # Before
        real 1m27.397s
        user 2m39.937s
        sys 0m5.966s

        # After
        real 1m13.443s ; -16%
        user 2m24.238s ; -10%
        sys 0m5.885s
        ```

        hotspot:tier1 improves with generic zapping optimization:

        ```
        # Before
        real 7m48.939s
        user 306m58.968s
        sys 27m29.886s

        # After
        real 7m38.203s ; -2%
        user 291m33.035s ; -5%
        sys 28m53.878s
        ```

              shade Aleksey Shipilev
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: