bsglz commented on PR #5171:
URL: https://github.com/apache/hbase/pull/5171#issuecomment-1513011277

   Rerun the tests in another way that run  the three compare methods one by 
one, and the results are different from above, not sure why, it seems to be 
some mutual interference.
   
   **1: Tested by PerfTestCellComparator2.java(the code shows below), used for 
region level to comping cells among stores.**
   
   <html xmlns:x="tencent"><meta charset="utf-8"><style type='text/css'><!-- td 
{ 
empty-cells:show;line-height:normal;color:#000;vertical-align:middle;outline-width:0;word-wrap:break-word;word-break:normal;white-space:nowrap;
 text-align:left;font-size:10pt; } table { border-collapse: collapse; } font{ 
white-space: pre-wrap }--></style><body><!--StartFragment-->
   
   compareMethod | leftFam | rightFam | comparator | cost(ms) | diff
   -- | -- | -- | -- | -- | --
   compareKV | fam | fam1 | CellComparatorOld | 21916 |  
   compareKV | fam | fam1 | CellComparatorImpl | 21612 | -1.00%
   compareKV | fam1 | fam2 | CellComparatorOld | 21970 |  
   compareKV | fam1 | fam2 | CellComparatorImpl | 21515 | -2.00%
   compareBBKV | fam | fam1 | CellComparatorOld | 22829 |  
   compareBBKV | fam | fam1 | CellComparatorImpl | 21821 | -4.00%
   compareBBKV | fam1 | fam2 | CellComparatorOld | 22659 |  
   compareBBKV | fam1 | fam2 | CellComparatorImpl | 21586 | -5.00%
   compareKVVsBBKV | fam | fam1 | CellComparatorOld | 19844 |  
   compareKVVsBBKV | fam | fam1 | CellComparatorImpl | 20020 | 1.00%
   compareKVVsBBKV | fam1 | fam2 | CellComparatorOld | 20140 |  
   compareKVVsBBKV | fam1 | fam2 | CellComparatorImpl | 19433 | -4.00%
   
   <!--EndFragment--></body></html>
   
   **2: Tested by PerfTestCellComparator.java(the code included in this PR), 
used for inner store comparing.**
   
   <html xmlns:x="tencent"><meta charset="utf-8"><style type='text/css'><!-- td 
{ 
empty-cells:show;line-height:normal;color:#000;vertical-align:middle;outline-width:0;word-wrap:break-word;word-break:normal;white-space:nowrap;
 text-align:left;font-size:10pt; } table { border-collapse: collapse; } font{ 
white-space: pre-wrap }--></style><body><!--StartFragment-->
   
   compareMethod | leftFam | rightFam | comparator | cost(ms) | diff
   -- | -- | -- | -- | -- | --
   compareKV | 0 | 0 | CellComparatorOld | 27251 |  
   compareKV | 0 | 0 | InnerStoreCellComparator | 25836 | -5.00%
   compareKV | 0 | 4 | CellComparatorOld | 17925 |  
   compareKV | 0 | 4 | InnerStoreCellComparator | 16482 | -8.00%
   compareKV | 4 | 0 | CellComparatorOld | 18043 |  
   compareKV | 4 | 0 | InnerStoreCellComparator | 16403 | -9.00%
   compareKV | 4 | 4 | CellComparatorOld | 30335 |  
   compareKV | 4 | 4 | InnerStoreCellComparator | 25700 | -15.00%
   compareBBKV | 0 | 0 | CellComparatorOld | 27888 |  
   compareBBKV | 0 | 0 | InnerStoreCellComparator | 26236 | -6.00%
   compareBBKV | 0 | 4 | CellComparatorOld | 19251 |  
   compareBBKV | 0 | 4 | InnerStoreCellComparator | 16870 | -12.00%
   compareBBKV | 4 | 0 | CellComparatorOld | 19290 |  
   compareBBKV | 4 | 0 | InnerStoreCellComparator | 16827 | -13.00%
   compareBBKV | 4 | 4 | CellComparatorOld | 31851 |  
   compareBBKV | 4 | 4 | InnerStoreCellComparator | 27387 | -14.00%
   compareKVVsBBKV | 0 | 0 | CellComparatorOld | 27563 |  
   compareKVVsBBKV | 0 | 0 | InnerStoreCellComparator | 28869 | 5.00%
   compareKVVsBBKV | 0 | 4 | CellComparatorOld | 18620 |  
   compareKVVsBBKV | 0 | 4 | InnerStoreCellComparator | 16031 | -14.00%
   compareKVVsBBKV | 4 | 0 | CellComparatorOld | 17629 |  
   compareKVVsBBKV | 4 | 0 | InnerStoreCellComparator | 16433 | -7.00%
   compareKVVsBBKV | 4 | 4 | CellComparatorOld | 30590 |  
   compareKVVsBBKV | 4 | 4 | InnerStoreCellComparator | 26643 | -13.00%
   
   <!--EndFragment--></body></html>
   
   Attach the other perf test class here, for one who interesting to test local:
   ```
   /*
    * 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.hadoop.hbase.regionserver;
   
   import java.nio.ByteBuffer;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.List;
   import org.apache.hadoop.hbase.ByteBufferKeyValue;
   import org.apache.hadoop.hbase.Cell;
   import org.apache.hadoop.hbase.CellComparator;
   import org.apache.hadoop.hbase.CellComparatorOld;
   import org.apache.hadoop.hbase.HBaseClassTestRule;
   import org.apache.hadoop.hbase.KeyValue;
   import org.apache.hadoop.hbase.testclassification.MediumTests;
   import org.apache.hadoop.hbase.util.Bytes;
   import org.apache.hadoop.hbase.util.Pair;
   import org.junit.ClassRule;
   import org.junit.Test;
   import org.junit.experimental.categories.Category;
   import org.junit.runner.RunWith;
   import org.junit.runners.Parameterized;
   
   /**
    * This is not a unit test. It is not run as part of the general unit test 
suite. It is for
    * comparing cell comparators. You must run it explicitly; e.g. mvn test
    * -Dtest=PerfTestCellComparator2
    */
   @Category({ MediumTests.class })
   @RunWith(Parameterized.class)
   public class PerfTestCellComparator2 {
   
     @ClassRule
     public static final HBaseClassTestRule CLASS_RULE =
       HBaseClassTestRule.forClass(PerfTestCellComparator.class);
   
     private static String COMPARE_KV = "compareKV";
     private static String COMPARE_BBKV = "compareBBKV";
     private static String COMPARE_KV_VS_BBKV = "compareKVVsBBKV";
   
     private CellComparator comparator;
     private Pair<byte[], byte[]> famPair;
     private String compareMethod;
   
     byte[] row1 = Bytes.toBytes("row1");
     byte[] qual1 = Bytes.toBytes("qual1");
     byte[] val = Bytes.toBytes("val");
   
     int compareCnt = 1000000000;
   
     @Parameterized.Parameters
     public static Collection<Object[]> data() {
   
       CellComparator[] cellComparators = new CellComparator[] 
{CellComparator.getInstance(),CellComparatorOld.OLD_COMPARATOR
       };
   
       String[] compareMethods = new String[] { COMPARE_KV_VS_BBKV};
       byte[] fam0 =Bytes.toBytes("fam");
       byte[] fam1 = Bytes.toBytes("fam1");
       byte[] fam2 = Bytes.toBytes("fam2");
       Pair<byte[], byte[]>[] famPairs = new Pair[] { new Pair(fam0, fam1),
         new Pair(fam1, fam2) };
   
       List<Object[]> params =
         new ArrayList<>(compareMethods.length * cellComparators.length * 
famPairs.length);
       for (String compareMethod : compareMethods) {
         for (Pair<byte[], byte[]> famPair : famPairs) {
           for (CellComparator cellComparator : cellComparators) {
             params.add(new Object[] { compareMethod, cellComparator, famPair 
});
           }
         }
       }
       return params;
     }
   
     public PerfTestCellComparator2(String compareMethod, CellComparator 
cellComparator,
       Pair<byte[], byte[]> famPair) {
       this.compareMethod = compareMethod;
       this.comparator = cellComparator;
       this.famPair = famPair;
     }
   
     @Test
     public void testComparePerf() {
       KeyValue kv1 = new KeyValue(row1, famPair.getFirst(), qual1, val);
       KeyValue kv2 = new KeyValue(row1, famPair.getSecond(), qual1, val);
   
       ByteBuffer buffer = ByteBuffer.wrap(kv1.getBuffer());
       Cell bbCell1 = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
       buffer = ByteBuffer.wrap(kv2.getBuffer());
       Cell bbCell2 = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
   
       long startTime = System.currentTimeMillis();
       if (this.compareMethod.equals(COMPARE_KV)) {
         for (int i = 0; i < compareCnt; i++) {
           comparator.compare(kv1, kv2);
         }
       } else if (this.compareMethod.equals(COMPARE_BBKV)) {
         for (int i = 0; i < compareCnt; i++) {
           comparator.compare(bbCell1, bbCell2);
         }
       } else if (this.compareMethod.equals(COMPARE_KV_VS_BBKV)) {
         for (int i = 0; i < compareCnt; i++) {
           comparator.compare(kv1, bbCell2);
         }
       }
   
       long costTime = System.currentTimeMillis() - startTime;
       System.out.println(
         compareMethod + "\t" + Bytes.toString(famPair.getFirst()) + "\t" + 
Bytes.toString(famPair.getSecond())
           + "\t" + comparator.getClass().getSimpleName() + "\t" + costTime);
     }
   
   }
   
   public class CellComparatorOld implements CellComparator {
   
     private static final long serialVersionUID = 8186411895799094989L;
   
     /**
      * Comparator for plain key/values; i.e. non-catalog table key/values. 
Works on Key portion of
      * KeyValue only.
      */
     public static final CellComparatorOld OLD_COMPARATOR = new 
CellComparatorOld();
   ...
   ```
   
   
   


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

Reply via email to