Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11425 Cell/DBB end-to-end on the read-path
  3. HBASE-14120

ByteBufferUtils#compareTo small optimization

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersConvert to IssueMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0
    • regionserver, Scanners
    • None
    • Reviewed

    Description

      We have it like

      if (UnsafeAccess.isAvailable()) {
        long offset1Adj, offset2Adj;
        Object refObj1 = null, refObj2 = null;
        if (buf1.hasArray()) {
      	offset1Adj = o1 + buf1.arrayOffset() + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;
      	refObj1 = buf1.array();
        } else {
      	offset1Adj = o1 + ((DirectBuffer) buf1).address();
        }
        if (buf2.hasArray()) {
      

      Instead of hasArray() check we can have isDirect() check and reverse the if else block. Because we will be making BB backed cells when it is offheap BB. So when code reaches here for comparison, it will be direct BB.

      Doing JMH test proves it.

      Benchmark                            Mode  Cnt         Score         Error  Units
      OnHeapVsOffHeapComparer.offheap     thrpt    4  50516432.643 ±  651828.103  ops/s
      OnHeapVsOffHeapComparer.offheapOld  thrpt    4  37696698.093 ± 1121685.293  ops/s
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            anoop.hbase Anoop Sam John Assign to me
            anoop.hbase Anoop Sam John
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment