Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
17, 21, 22
-
b17
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8320776 | 21.0.2 | Aleksey Shipilev | P4 | Resolved | Fixed | b09 |
Description
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.
Attachments
Issue Links
- backported by
-
JDK-8320776 Improve performance of Symbol::print_value_on()
-
- Resolved
-