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

BlockCacheKey toString Performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 3.0.0-alpha-1
    • 1.3.2, 1.4.1, 2.0.0-beta-1, 2.0.0, 1.2.7
    • None
    • None
    • Reviewed

    Description

        @Override
        public String toString() {
          return String.format("%s_%d", hfileName, offset);
        }
      

      I found through bench-marking that the following code is 10x faster.

        @Override
        public String toString() {
          return hfileName.concat("_").concat(Long.toString(offset));
        }
      

      Normally it wouldn't matter for a toString() method, but this is comes into play because MemcachedBlockCache uses it.

      MemcachedBlockCache.java
        @Override
        public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf) {
          if (buf instanceof HFileBlock) {
            client.add(cacheKey.toString(), MAX_SIZE, (HFileBlock) buf, tc);
          } else {
            if (LOG.isDebugEnabled()) {
              LOG.debug("MemcachedBlockCache can not cache Cacheable's of type "
                  + buf.getClass().toString());
            }
          }
        }
      

      Attachments

        1. HBASE-19684.1.patch
          0.7 kB
          David Mollitor
        2. HBASE-19684.2.patch
          0.7 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: