Closed
Conversation
Signed-off-by: Anthony Petrov <[email protected]>
imalygin
reviewed
Oct 3, 2025
pbj-integration-tests/src/jmh/java/com/hedera/pbj/integration/jmh/utf8/Utf8ToolsV2.java
Outdated
Show resolved
Hide resolved
imalygin
previously approved these changes
Oct 3, 2025
Signed-off-by: Anthony Petrov <[email protected]>
Signed-off-by: Anthony Petrov <[email protected]>
imalygin
approved these changes
Oct 3, 2025
Member
|
For concern(1) I have one idea but don't love it. You could make the On concern (2) we should get a performance run with this branch by Alex to see how it effects CN performance before merging. If the gain is tiny or non-existent then lets not merge. |
Contributor
Author
|
Closing the PR per #620 (comment) . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This is the last part of changes extracted from @jasperpotts 's draft PoC #612 . We store string fields as UTF-8 byte arrays internally in models. We allow codecs to parse original UTF-8 and implant them directly into the model w/o performing the UTF-8 decoding (which internally would convert the text into UTF-16 (or Latin-1) because that's how Java stores strings.) The public API of the models is unchanged, and whenever anyone calls a getter for a string field, the model will encode it into a Java string on the fly.
The idea behind this optimization is that we rarely read or use strings in our business logic. So we could as well skip the decoding part when parsing models.
Three caveats come with the fix:
byte[]for strings and also have a fake unused argument so as to resolve a generic erasure clash. This looks a bit ugly. Also, this is not very safe because it allows a malicious code to create a mutable model instance (by retaining references to theirbyte[]) and then pass the object to a code that expects the models to be immutable. We could make the constructorsprivate, but we'd have to move all the codecs into the same package with their models, which could be a breaking change.Related issue(s):
Fixes #620
Notes for reviewer:
All tests should pass.
Checklist