[ 
https://issues.apache.org/jira/browse/SOLR-16328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107135#comment-18107135
 ] 

David Smiley commented on SOLR-16328:
-------------------------------------

A contributor (more concretely their AI tooling) noticed basically dead code 
around this interning. It surprised me so I had Claude research what happened:
----
STR_INTERNER_OBJ_BUILDER was introduced in SOLR-16328 ("intern() strings in 
DocCollection to reduce memory footprint"), commit 1b7ff717b19 / 977a8464173 
(Noble Paul,
2022-09-07). That PR only touched ClusterState.java and CoreContainer.java — it 
added the field, setStrInternerParser(), wired 
CoreContainer.setWeakStringInterner() to
call it, and made ClusterState.createFromJson use it via Utils.fromJSON(bytes, 
0, bytes.length, STR_INTERNER_OBJ_BUILDER).

The catch: even at the moment of that commit, the real per-collection ZK read 
path (ZkStateReader.fetchCollectionState) did not call 
ClusterState.createFromJson. It
called a separate helper, 
ZkClientClusterStateProvider.createFromJsonSupportingLegacyConfigName, which 
parsed with plain Utils.fromJSON(bytes) (no interner) and then
called ClusterState.createFromCollectionMap directly. So the interning was 
never actually wired into the live "read state.json from ZK" hot path — it only 
ever affected
ClusterState.createFromJson, whose only callers are BackupManager (collection 
backup/restore) and unit tests.

That legacy helper (createFromJsonSupportingLegacyConfigName) was later removed 
in SOLR-18166 ("Remove 'linkconfig' tool and related code", PR #4232, commit 
bfda10e9519 /
ebe71e48f03, merged 2026-03-25 by Jason Gerlowski). That change inlined the 
same plain Utils.fromJSON(data) + ClusterState.createFromCollectionMap logic 
directly into
fetchCollectionState — i.e., it preserved the existing (non-interning) behavior 
rather than removing an interning capability that was there before.

{*}Bottom line{*}: this isn't a case of the interner having been actively used 
and then disabled by a specific commit — the live per-collection ZK load path 
never exercised
STR_INTERNER_OBJ_BUILDER, going all the way back to when it was added in 2022. 
It's effectively only reachable today via BackupManager/tests. This looks like 
it was
likely an oversight in the original SOLR-16328 change (the interning got 
applied to the wrong/unused JSON-parsing entry point).
----
(ugh, embarassing)

Consequently, I'm going to approve the complete removal as if it never happened.

> intern() strings in DocCollection to reduce memory footprint
> ------------------------------------------------------------
>
>                 Key: SOLR-16328
>                 URL: https://issues.apache.org/jira/browse/SOLR-16328
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Noble Paul
>            Assignee: Noble Paul
>            Priority: Major
>             Fix For: 9.1
>
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> strings used in a {{state,json}} are usually repeated and they are long 
> lived. intern the strings to reduce the no:of objects



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to