[ https://issues.apache.org/jira/browse/HBASE-20716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16523681#comment-16523681 ]
Sahil Aggarwal commented on HBASE-20716: ---------------------------------------- [~stack] What I got from description and some code reading is that we want to remove these booleans: UNSAFE_UNALIGNED LITTLE_ENDIAN probably because these checks happen in hot code path and can be avoided by checking the same at startup and assigned the relevant handler. Tried running jmh on 2 versions: one with flag and another without flag, after making it final there seem to be almost no difference. +non-final flag LITTLE_ENDIAN:+ Result "org.sample.UnsafeAccessBenchmark.testUnsafeWithFlag": 2178237030.784 ops/s Result "org.sample.UnsafeAccessBenchmark.testUnsafeWithoutFlag": 3255613805.960 ops/s +final flag LITTLE_ENDIAN:+ Result "org.sample.UnsafeAccessBenchmark.testUnsafeWithFlag": 3243770223.012 ops/s Result "org.sample.UnsafeAccessBenchmark.testUnsafeWithoutFlag": 3256975533.152 ops/s > Unsafe access cleanup > --------------------- > > Key: HBASE-20716 > URL: https://issues.apache.org/jira/browse/HBASE-20716 > Project: HBase > Issue Type: Improvement > Components: Performance > Reporter: stack > Priority: Critical > Labels: beginner > > We have two means of getting at unsafe; UnsafeAccess and then internal to the > Bytes class. They are effectively doing the same thing. We should have one > avenue to Unsafe only. > Many of our paths to Unsafe via UnsafeAccess traverse flags to check if > access is available, if it is aligned and the order in which words are > written on the machine. Each check costs -- especially if done millions of > times a second -- and on occasion adds bloat in hot code paths. The unsafe > access inside Bytes checks on startup what the machine is capable off and > then does a static assign of the appropriate class-to-use from there on out. > UnsafeAccess does not do this running the checks everytime. Would be good to > have the Bytes behavior pervasive. > The benefit of one access to Unsafe only is plain. The benefits we gain > removing checks will be harder to measure though should be plain when you > disassemble a hot-path; in a (very) rare case, the saved byte codes could be > the difference between inlining or not. -- This message was sent by Atlassian JIRA (v7.6.3#76005)