HBase
  1. HBase
  2. HBASE-6968

Several HBase write perf improvement

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.90.6, 0.92.2, 0.94.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Here are 2 hbase write performance improvements recently:

      1) Avoid creating HBaseConfiguraiton object for each HLog. Every time when creating a HBaseConfiguraiton object, it would parse the xml configuration files from disk, which is not cheap operation.
      In HLog.java:
      orig:

      HLog.java
        newWriter = createWriter(fs, newPath, HBaseConfiguration.create(conf));
      

      new:

        newWriter = createWriter(fs, newPath, conf);
      

      2) Change 2 hotspot synchronized functions into double locking pattern. So it shall remove the synchronization overhead in the normal case.
      orig:

      HBaseRpcMetrics.java
        public synchronized void inc(String name, int amt) {	
          MetricsTimeVaryingRate m = get(name);	
          if (m == null) {	
            m = create(name);	
          }	
          m.inc(amt);	
        }
      

      new:

        public void inc(String name, int amt) {	
          MetricsTimeVaryingRate m = get(name);	
          if (m == null) {	
            synchronized (this) {	
              if ((m = get(name)) == null) {	
                m = create(name);	
              }	
            }	
          }	
          m.inc(amt);	
        }
      

      =====================
      orig:

      MemStoreFlusher.java
        public synchronized void reclaimMemStoreMemory() {	
          if (this.server.getGlobalMemstoreSize().get() >= globalMemStoreLimit) {	
            flushSomeRegions();	
          }
        }	
      

      new:

        public void reclaimMemStoreMemory() {	
          if (this.server.getGlobalMemstoreSize().get() >= globalMemStoreLimit) {	
            flushSomeRegions();	
          }
        }	
        private synchronized void flushSomeRegions() {	
          if (this.server.getGlobalMemstoreSize().get() < globalMemStoreLimit) {	
            return; // double check the global memstore size inside of the synchronized block.	
          }	
       ...   
       }
      

        Activity

        Hide
        Liang Xie added a comment -

        I look through trunk code, there's no change needed, so let's set this affects issue version on 0.90/0.92/0.94 only, right ?

        Show
        Liang Xie added a comment - I look through trunk code, there's no change needed, so let's set this affects issue version on 0.90/0.92/0.94 only, right ?
        Hide
        Lars Hofhansl added a comment -

        Looks like the first two changes are (in one form or the other) in 0.94+ already.

        The 0.94 MemStoreFlusher.reclaimMemStoreMemory looks bad, though. We are taking a lock and are awaiting a condition inside a synchronized method... It seems we can remove the synchronized there. The code inside the method does not need it and there are no other synchronized methods (or synchronized(this) blocks) in the class (which is also why it is not noticeably bad, because nothing is locked out).

        Show
        Lars Hofhansl added a comment - Looks like the first two changes are (in one form or the other) in 0.94+ already. The 0.94 MemStoreFlusher.reclaimMemStoreMemory looks bad, though. We are taking a lock and are awaiting a condition inside a synchronized method... It seems we can remove the synchronized there. The code inside the method does not need it and there are no other synchronized methods (or synchronized(this) blocks) in the class (which is also why it is not noticeably bad, because nothing is locked out).
        Hide
        ramkrishna.s.vasudevan added a comment -

        Nice one.

        Show
        ramkrishna.s.vasudevan added a comment - Nice one.

          People

          • Assignee:
            Unassigned
            Reporter:
            Liyin Tang
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:

              Development