Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-25510

Optimize TableName.valueOf from O(n) to O(1). We can get benefits when the number of tables in the cluster is greater than dozens

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 1.2.12, 1.4.13, 2.4.1
    • 3.0.0-beta-2
    • master, Replication
    • None

    Description

      Now, TableName.valueOf will try to find TableName Object in cache linearly(code show as below). So it is too slow when we has  thousands of tables on cluster.

      // code placeholder
      for (TableName tn : tableCache) {
        if (Bytes.equals(tn.getQualifier(), qns) && Bytes.equals(tn.getNamespace(), bns)) {
          return tn;
        }
      }

      I try to store the object in the hash table, so it can look up more quickly. code like this

      // code placeholder
      TableName oldTable = tableCache.get(nameAsStr);

       

      In our cluster which has tens thousands of tables. (Most of that is KYLIN table). 
      We found that in the following two cases, the TableName.valueOf method will severely restrict our performance.
       
      Common premise: tens of thousands table in cluster
      cause: TableName.valueOf with low performance. (because we need to traverse all caches linearly)
       
      Case1. Replication
      premise1: one of table write with high qps, small value, Non-batch request. cause too much wal entry

      premise2: deserialize WAL Entry includes calling the TableName.valueOf method.

      Cause: Replicat Stuck. A lot of WAL files pile up.

       

      Case2. Active Master Start up

      NamespaceStateManager init should init all RegionInfo, and regioninfo init will call TableName.valueOf.  It will cost some time if TableName.valueOf is slow.
       

      Attachments

        1. optimiz_benchmark
          18 kB
          zhuobin zheng
        2. optimiz_benchmark_fix
          16 kB
          zhuobin zheng
        3. origin_benchmark
          15 kB
          zhuobin zheng
        4. stucks-profile-info
          5 kB
          zhuobin zheng
        5. TestTableNameJMH.java
          3 kB
          zhuobin zheng

        Issue Links

          Activity

            People

              zhengzhuobinzzb zhuobin zheng
              zhengzhuobinzzb zhuobin zheng
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: