-
Enhancement
-
Resolution: Fixed
-
P4
-
17, 21, 22
-
b17
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8320776 | 21.0.2 | Aleksey Shipilev | P4 | Resolved | Fixed | b09 |
JDK-8341420 | 17.0.14 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
During investigation of performance of class unloading I found that logging the unloading event (UnloadingEventLog::log()) takes 20-40% of total class unloading time.
The problem seems to be Symbol::print_value_on().
The code is:
void Symbol::print_value_on(outputStream* st) const {
st->print("'");
for (int i = 0; i < utf8_length(); i++) {
st->print("%c", char_at(i));
}
st->print("'");
}
I.e. ultimately uses snprintf for every character of the symbol. The code seems to print the raw utf-8 string (ju)byte by (ju)byte.
A faster way seems to be just use outputStream::write() since apparently the code wants to print the raw utf8 bytes anyway:
st->write("'", 1);
st->write((const char*)base(), utf8_length());
st->write("'", 1);
Initial tests showed that this is ~5-10x faster, reducing the overhead of event logging during class unloading significantly.
The problem seems to be Symbol::print_value_on().
The code is:
void Symbol::print_value_on(outputStream* st) const {
st->print("'");
for (int i = 0; i < utf8_length(); i++) {
st->print("%c", char_at(i));
}
st->print("'");
}
I.e. ultimately uses snprintf for every character of the symbol. The code seems to print the raw utf-8 string (ju)byte by (ju)byte.
A faster way seems to be just use outputStream::write() since apparently the code wants to print the raw utf8 bytes anyway:
st->write("'", 1);
st->write((const char*)base(), utf8_length());
st->write("'", 1);
Initial tests showed that this is ~5-10x faster, reducing the overhead of event logging during class unloading significantly.
- backported by
-
JDK-8320776 Improve performance of Symbol::print_value_on()
- Resolved
-
JDK-8341420 Improve performance of Symbol::print_value_on()
- Resolved
- links to
-
Commit openjdk/jdk21u/4d5ceb41
-
Commit openjdk/jdk/90bcdbd1
-
Commit(master) openjdk/jdk17u-dev/2d963ac2
-
Review openjdk/jdk21u/394
-
Review openjdk/jdk/15838
-
Review(master) openjdk/jdk17u-dev/2895
(3 links to)