[Netty 5] Is AsciiString still useful ?
See original GitHub issueJDK 9+ includes JEP 254 Compact String which can use a byte[]
instead of a char[] as the backing storage for String
in some situations. The primary reason for introducing AsciiString
was to reduce memory for storage of headers. We should investigate if String
can now be used instead. We would likely have to wrap String
to be able to override the hashCode
algorithm to be case insensitive. If we do decide to keep AsciiString
the constant memory overhead for smaller string is quite high because we maintain array/offset to avoid copying in some situations. We should investigate if this is beneficial/necessary as it can also lead to longer retention of larger byte[]
objects.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Netty 5.0.0.Alpha5 released - Netty.news
Buffer leak detection has been improved, and numerous leaks have been fixed as a result. Mutation methods have been removed from AsciiString ....
Read more >AsciiString (Netty API Reference (4.1.85.Final))
This class was designed to provide an immutable array of bytes, and caches some internal state based upon the value of this array....
Read more >New and noteworthy in 5.0 - Netty.docs
This document walks you through the list of notable changes and new features in the major Netty release (since 4.1) to give you...
Read more >New and noteworthy in 4.1 - Netty.docs
You will find this class useful when you deal with a US-ASCII or ISO-8859-1 string. For instance, the HTTP codec and STOMP codec...
Read more >NetUtil xref - Netty
If failed to get the value, {@code 200} is used as a 75 * default value for ... 6 || 508 // a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As part of this, can we also re-evaluate API’s that return a
CharSequence
rather than aString
?I think
CharSequence
should be the preferred input type, butString
should be the only return type.String
is the de facto string representation used throughout most of Java, and I sometimes have to write cumbersome logic like this:@normanmaurer In ServiceTalk, we have a similar class AsciiBuffer, that implements
CharSequence
interface. But in ServiceTalk motivation is different: we do that to avoid copying of the header names and values (we can do that because we do not use pooled memory) and to optimize the writes (avoid serialization ofString
) side. According to our benchmarks it gives advantages on JDK11. So, “reduce memory for storage of headers” is not the primary motivation in our use-case.