-
Notifications
You must be signed in to change notification settings - Fork 182
[JBTM-4014] Reduce allocation pressure on Uid #2427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Author is not the 'narayana' contributor, to permit PR being run members of jbosstm can write comment of text: TESTIT |
|
@marcosgopen I've removed the existing One note:
hostAddr = Utility.hostInetAddr(); /* calculated only once */
process = Utility.getpid();why not lazily encode and cache both hex values for these? |
|
TESTIT |
|
Thanks @franz1981 for opening this PR. FYI the unit tests for Uid are here: https://github.com/jbosstm/narayana/blob/main/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUnitTest.java. |
Yeah, I notice that while reviewing the PR. We should see if it makes a difference to the benchmarks and then follow up with the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good PR and the performance improvement is very worthwhile. I learnt some new things and although I did not fully understand the hex char manipulations in Utility.java they are clearly working.
I forgot to wait for the CI run, I will trigger one manually.
|
CORE profile tests failed (https://jenkins-csb-narayana-ci.dno.corp.redhat.com/job/btny-pulls-narayana/PROFILE=CORE,jdk=openJDK17,label=jnlp-agent/46/): Narayana rebase on main failed. Please rebase it manually |
Sorry @franz1981 but CI is reporting that the PR needs a rebase. |
57127b3 to
4df0c88
Compare
|
|
||
| // check the min/max string and file string forms | ||
|
|
||
| assertEquals("-8000000000000000:-8000000000000000:-80000000:-80000000:-80000000", minUid.stringForm()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added these since relevant for the hex encoding @marcosgopen
|
Author is not the 'narayana' contributor, to permit PR being run members of jbosstm can write comment of text: TESTIT [edit by mmusgrov] I triggered build 49 and the 51 |
|
Started testing this pull request with CORE profile: https://jenkins-csb-narayana-ci.dno.corp.redhat.com/job/btny-pulls-narayana/PROFILE=CORE,jdk=openJDK17,label=jnlp-agent/51/ |
|
Started testing this pull request with CORE profile: https://jenkins-csb-narayana-ci.dno.corp.redhat.com/job/btny-pulls-narayana/PROFILE=CORE,jdk=openJDK21,label=jnlp-agent/51/ |
|
CORE profile tests passed - Job complete https://jenkins-csb-narayana-ci.dno.corp.redhat.com/job/btny-pulls-narayana/PROFILE=CORE,jdk=openJDK17,label=jnlp-agent/51/ |
|
CORE profile tests passed - Job complete https://jenkins-csb-narayana-ci.dno.corp.redhat.com/job/btny-pulls-narayana/PROFILE=CORE,jdk=openJDK21,label=jnlp-agent/51/ |
mmusgrov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resubmitting the review since the CI run passed..
mmusgrov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resubmitting the review since the CI run passed..
marcosgopen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am approving too after having tested the improvement locally. See my comment jbosstm/performance#185 (comment)
https://issues.redhat.com/browse/JBTM-4014
CORE !AS_TESTS !RTS !JACOCO !XTS !QA_JTA !QA_JTS_OPENJDKORB PERFORMANCE !DB_TESTS
This pull request refactors the
Uidclass and related utility methods to improve performance and memory usage by replacing stream-based serialization/deserialization with direct byte array manipulation and optimized hex string conversion. The changes also introduce new helper methods inUtility.javafor more efficient hex conversions, and update usages inUid.javato leverage these helpers.The most important changes are:
Performance and Memory Optimization:
ByteArrayInputStream/DataInputStreamandByteArrayOutputStream/DataOutputStreamwith direct byte array access usingVarHandlefor reading and writing UID fields inUid.java. This avoids object allocation and improves performance. [1] [2]AtomicReferenceFieldUpdaterfor_byteFormto ensure thread-safe lazy initialization of UID byte representation.Hex String Conversion Improvements:
hexCharsOf,toHexChars) toUtility.javafor efficiently determining hex string length and convertingint/longvalues to hex ASCII bytes, replacing previous string-based conversions.Uid.stringForm()andUid.fileStringForm()to use the new byte-based hex conversion helpers, improving speed and reducing allocations.Code Modernization and Consistency:
Uid.javafromchartobytefor consistency with new byte array logic.Utility.javafor fast lookup during hex conversions.