You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "psalagnac (via GitHub)" <gi...@apache.org> on 2026/05/11 13:50:01 UTC

[PR] SOLR-18237: Do not copy data before noggit parsing [solr]

psalagnac opened a new pull request, #4415:
URL: https://github.com/apache/solr/pull/4415

   https://issues.apache.org/jira/browse/SOLR-18237
   
   This removes the `char[]` array buffer when parsing collection state (and other Json data). Instead, the UTF8 decoding is done on the fly using JVM tolling (which I guess will be faster).
   By default, the JSON parser has an internal buffer of 8K.
   


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18237: Do not copy data before noggit parsing [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4415:
URL: https://github.com/apache/solr/pull/4415#discussion_r3238629314


##########
changelog/unreleased/SOLR-18237-no-buffer.yml:
##########
@@ -0,0 +1,7 @@
+title: Do not copy full data for UTF8 to Java string conversion for deserializing a collection state
+type: fixed

Review Comment:
   users will not perceive this as a fix of a bug.  It's "changed".  But I'm skeptical it warrants a changelog at all.



##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -297,16 +294,10 @@ public static Object fromJSON(
     if (utf8 == null || utf8.length == 0 || length == 0) {
       return Map.of();
     }
-    // convert directly from bytes to chars
-    // and parse directly from that instead of going through
-    // intermediate strings or readers
-    CharArr chars = new CharArr();
-    ByteUtils.UTF8toUTF16(utf8, offset, length, chars);
-    JSONParser parser = new JSONParser(chars.getArray(), chars.getStart(), chars.length());
-    parser.setFlags(
-        parser.getFlags()
-            | JSONParser.ALLOW_MISSING_COLON_COMMA_BEFORE_OBJECT
-            | JSONParser.OPTIONAL_OUTER_BRACES);
+    // convert from bytes to chars on-the-fly and parse directly
+    // from that instead of going through intermediate buffers
+    Reader reader = new InputStreamReader(new ByteArrayInputStream(utf8, offset, length), UTF_8);

Review Comment:
   this is definitely the most natural/clear way to do things instead of anything else.  Maybe it's faster; I trust your judgement.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18237: Do not copy data before noggit parsing [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #4415:
URL: https://github.com/apache/solr/pull/4415#issuecomment-4431987278

   this looks like it make sense, however it would be awesome if we had a micro benchmark here?


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18237: Do not copy data before noggit parsing [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #4415:
URL: https://github.com/apache/solr/pull/4415#discussion_r3420819225


##########
changelog/unreleased/SOLR-18237-no-buffer.yml:
##########
@@ -0,0 +1,7 @@
+title: Do not copy full data for UTF8 to Java string conversion for deserializing a collection state
+type: fixed

Review Comment:
   From the comments in the PR, there is a misunderstanding on the intention. The PR description indeed does not mention it, as the change log 😅 
   
   Main goal is not a performance optimization but to avoid OMM errors. I explained this in the Jira. We had many OOM repos and this trivial change had a huge for our case.
   I'll make this statement clearer in the changelog entry.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18237: Do not copy data before noggit parsing [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac merged PR #4415:
URL: https://github.com/apache/solr/pull/4415


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org