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/11 00:53:04 UTC

[GitHub] [solr] markrmiller opened a new pull request #255: SOLR-15560: Look into JIT optimization in JavaBin.

markrmiller opened a new pull request #255:
URL: https://github.com/apache/solr/pull/255


   Initially this is just a quick exploration on decode perf, encode perf still to do.
   
   Basic benchmark will encode/decode a NamedList with a few typical entries as well as 30 SolrDocuments in a SolrDocumentList by default.


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


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

Posted by GitBox <gi...@apache.org>.
HoustonPutman commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r705571481



##########
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:
       It's included in the server jars anyways now: https://github.com/apache/solr/blob/main/solr/server/build.gradle#L75




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


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

Posted by GitBox <gi...@apache.org>.
markrmiller commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r704711822



##########
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:
       Well that's a silly question. Logging has tremendous performance impact. Format has tremendous logging impact.
   
   Regardless, this issue was part of standing up a benchmark system on the benchmark module, and the code from month ago has little bearing. Indicated by initial, initial, and quick exploration.




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


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

Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r704916042



##########
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:
       I mean, why log in JSON in particular?  Apparently you felt it was important enough that it warranted an additional dependency, which is fine with me, but it's curious to me.




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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r687111935



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
##########
@@ -954,8 +1063,8 @@ protected CharSequence readUtf8(DataInputInputStream dis) throws IOException {
   protected CharSequence readUtf8(DataInputInputStream dis, int sz) throws IOException {
     ByteArrayUtf8CharSequence result = new ByteArrayUtf8CharSequence(null,0,0);
     if(dis.readDirectUtf8(result, sz)){
-     result.stringProvider= getStringProvider();
-     return result;
+      result.stringProvider= getStringProvider();
+      return result;
     }
 
     if (sz > MAX_UTF8_SZ) return _readStr(dis, null, sz);

Review comment:
       *NULL_DEREFERENCE:*  object `null` is dereferenced by call to `_readStr(...)` at line 1070.
   (at-me [in a reply](https://help.sonatype.com/lift) with `help` or `ignore`)




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


[GitHub] [solr] markrmiller commented on pull request #255: SOLR-15560: Look into JIT optimization in JavaBin.

Posted by GitBox <gi...@apache.org>.
markrmiller commented on pull request #255:
URL: https://github.com/apache/solr/pull/255#issuecomment-896478156


   So far, initial summary is:
   
   79% improvement for decode performance for this benchmark.
   327% improvement for encode performance for this benchmark.


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


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

Posted by GitBox <gi...@apache.org>.
markrmiller commented on pull request #255:
URL: https://github.com/apache/solr/pull/255#issuecomment-915509941


   Review on this WIP code from 29 days has little value.


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


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

Posted by GitBox <gi...@apache.org>.
dsmiley commented on pull request #255:
URL: https://github.com/apache/solr/pull/255#issuecomment-920417756


   I'm trying to follow along but the most recent commit appears to have auto-formatted a bunch of files.  Can you please undo that; maybe even force-push a correction?  As a project, we've got spotless integrated but not yet enabled for these modules; only one so far.


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


[GitHub] [solr] markrmiller commented on pull request #255: SOLR-15560: Look into JIT optimization in JavaBin.

Posted by GitBox <gi...@apache.org>.
markrmiller commented on pull request #255:
URL: https://github.com/apache/solr/pull/255#issuecomment-896417540


   I've put an initial before/after comparison for JavaBinCodec decode performance in the JIRA issue: https://issues.apache.org/jira/browse/SOLR-15560


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


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

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r689803753



##########
File path: solr/benchmark/src/java/org/apache/solr/bench/BaseBenchState.java
##########
@@ -0,0 +1,57 @@
+package org.apache.solr.bench;
+
+import org.apache.solr.common.util.SuppressForbidden;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.BenchmarkParams;
+
+import java.util.Random;
+import java.util.SplittableRandom;
+
+@State(Scope.Benchmark)
+public class BaseBenchState {
+
+  private static final long RANDOM_SEED = 6624420638116043983L;
+
+  private SplittableRandom random;
+
+  public static boolean quietLog = Boolean.getBoolean("quietLog");
+
+  @SuppressForbidden(reason = "JMH uses std out for user output")
+  public static void log(String value) {
+    if (!quietLog) {
+      System.out.println((value.equals("") ? "" : "--> ") + value);
+    }
+  }
+
+  @Setup(Level.Trial)
+  public void doSetup(BenchmarkParams benchmarkParams) throws Exception {
+    System.setProperty("solr.log.name", benchmarkParams.id());
+
+    Long seed = getRandomSeed();
+
+    this.random = new SplittableRandom(seed);
+  }
+
+
+  public static Long getRandomSeed() {
+    Long seed = Long.getLong("solr.bench.seed");
+
+    if (seed == null) {
+      seed = RANDOM_SEED;
+    }
+
+    log("benchmark random seed: " + seed);
+
+    // set the seed used by hard to reach places
+    System.setProperty("randomSeed", Long.toString(new Random(seed).nextLong()));

Review comment:
       *PREDICTABLE_RANDOM:*  This random generator (java.util.Random) is predictable [(details)](https://find-sec-bugs.github.io/bugs.htm#PREDICTABLE_RANDOM)
   (at-me [in a reply](https://help.sonatype.com/lift) with `help` or `ignore`)




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