You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/08/27 18:46:55 UTC

[GitHub] [solr] dsmiley commented on a change in pull request #255: SOLR-15560: Optimize JavaBinCodec encode/decode performance.

dsmiley commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r697624329



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
##########
@@ -935,9 +1046,7 @@ private CharSequence _readStr(DataInputInputStream dis, StringCache stringCache,
     if (stringCache != null) {
       return stringCache.get(bytesRef.reset(bytes, 0, sz));
     } else {
-      arr.reset();
-      ByteUtils.UTF8toUTF16(bytes, 0, sz, arr);
-      return arr.toString();
+      return new String(bytes, 0, sz, StandardCharsets.UTF_8);

Review comment:
       Curious why

##########
File path: solr/benchmark/build.gradle
##########
@@ -69,6 +69,8 @@ private static String toPath(Set<File> classpathUnderTest) {
 dependencies {
   implementation project(':solr:test-framework')
 
+  implementation 'org.apache.logging.log4j:log4j-layout-template-json'

Review comment:
       Why do we care about the logging format for benchmarking?

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
##########
@@ -900,21 +1008,24 @@ public void writeStr(CharSequence s) throws IOException {
     int maxSize = end * ByteUtils.MAX_UTF8_BYTES_PER_CHAR;
 
     if (maxSize <= MAX_UTF8_SIZE_FOR_ARRAY_GROW_STRATEGY) {
-      if (bytes == null || bytes.length < maxSize) bytes = new byte[maxSize];
-      int sz = ByteUtils.UTF16toUTF8(s, 0, end, bytes, 0);
-      writeTag(STR, sz);
-      daos.write(bytes, 0, sz);
+      byte[] stringBytes = ((String)s).getBytes(StandardCharsets.UTF_8);

Review comment:
       no longer re-uses `bytes` field.  This is better?

##########
File path: solr/solrj/src/java/org/apache/solr/common/SolrDocument.java
##########
@@ -46,7 +46,8 @@
   protected final Map<String,Object> _fields;
   
   private List<SolrDocument> _childDocuments;
-  
+  private MyEntryWriter entryWriter;

Review comment:
       this field is a shame; are you sure it is worth it?  If it stays, it definitely needs comments to explain it; also referring to this JIRA issue

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
##########
@@ -305,129 +350,183 @@ protected Object readObject(DataInputInputStream dis) throws IOException {
         return readExternString(dis);
     }
 
+    // if ((tagByte & 0xe0) == 0) {
+    // if top 3 bits are clear, this is a normal tag
+
     switch (tagByte) {

Review comment:
       I've seen this before and pondered if it would be more efficient to dispatch to an array of lambdas indexed by the tag Byte?  But then I suppose the JIT could internally do such tricks -- dunno if it does.

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/AlreadyBufferedOutputStream.java
##########
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.common.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+
+/**
+ * A subclass of {@link FastOutputStream} that avoids all buffering and writes directly to the {@link OutputStream}.

Review comment:
       Why subclass FastOutputStream if we aren't using its buffer?  Are expecting a FOS in some cases (maybe we should be less strict?




-- 
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