-
Enhancement
-
Resolution: Fixed
-
P4
-
11, 17, 19, 20
-
b08
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8311093 | 17.0.9 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
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
```
$ 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
```
- backported by
-
JDK-8311093 Optimize ResourceArea zapping on ResourceMark release
-
- Resolved
-
- relates to
-
JDK-8290495 Micro-optimize Method::can_be_statically_bound assertions
-
- Resolved
-
-
JDK-8290728 Optimize HandleArea zapping on HandleMark release
-
- Closed
-
- links to
-
Commit openjdk/jdk17u-dev/295cf447
-
Commit openjdk/jdk/7841e5cc
-
Review openjdk/jdk17u-dev/1452
-
Review openjdk/jdk/9543
(2 links to)