RongtongJin commented on code in PR #10444:
URL: https://github.com/apache/rocketmq/pull/10444#discussion_r3388183556
##########
common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java:
##########
@@ -102,6 +106,18 @@ public class MessageConst {
public static final HashSet<String> STRING_HASH_SET = new HashSet<>(64);
+ // Mirrors STRING_HASH_SET. Used by MessageDecoder.string2messageProperties
+ // to swap freshly-allocated key substrings for the canonical interned
String,
+ // dropping ~50B per well-known key per message under load.
+ public static final Map<String, String> STRING_INTERN_MAP = new
HashMap<>(128);
Review Comment:
These intern caches are exposed as public mutable state. `MessageDecoder`
now depends on `STRING_INTERN_BY_LEN` for parsing fast paths, so external code
could mutate the map or the arrays and change decoder behavior globally. Could
we keep these structures private/package-private, or expose only immutable
views? Also, `STRING_INTERN_MAP` does not appear to be used by the current hot
path; if it is only a build-time helper for `STRING_INTERN_BY_LEN`, it would be
safer not to expose it as a public API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]