You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/01/22 03:36:31 UTC
[GitHub] [hbase] zhengzhuobinzzb commented on pull request #2885: HBASE-25510 Optimize TableName.valueOf from O(n) to O(1)
zhengzhuobinzzb commented on pull request #2885:
URL: https://github.com/apache/hbase/pull/2885#issuecomment-765098428
> It is a bit strange that we convert bytes or ByteBuffer to String, and then convert back to store them...
Thank you very much for reviewing my code.
In face, i tryed to use ByteBuffer as hash key. But there ars some reasons i choose String finally.
1. Because we use hashmap, so we must choose a class as hash key. Therefore, we must convert one of String and ByteBuffer to the other.
2. Use ByteBuffer alse need to copy underlying array. If not, might cause memory leak.
3. The code for construct hash key(${namespace} + ':' + ${tablename}), String is more concise than ByteBuffer.
4. In my benchmark(code can find in jira attachment). The efficiency of String is a little better than ByteBuffer overall.
Benchmark Result For ByteBuffer:
Benchmark Mode Cnt Score Error Units
TestTableNameJMH.testBB1 thrpt 10 73319.634 ± 5162.112 ops/ms
TestTableNameJMH.testBB10 thrpt 10 69742.749 ± 1238.255 ops/ms
TestTableNameJMH.testBB100 thrpt 10 65220.820 ± 3357.727 ops/ms
TestTableNameJMH.testBB1000 thrpt 10 47865.385 ± 2510.229 ops/ms
TestTableNameJMH.testBB10000 thrpt 10 29383.002 ± 5535.025 ops/ms
TestTableNameJMH.testBB100000 thrpt 10 15333.042 ± 3451.444 ops/ms
TestTableNameJMH.testStr1 thrpt 10 17342.604 ± 2997.854 ops/ms
TestTableNameJMH.testStr10 thrpt 10 18562.438 ± 1984.190 ops/ms
TestTableNameJMH.testStr100 thrpt 10 16152.466 ± 3349.675 ops/ms
TestTableNameJMH.testStr1000 thrpt 10 14944.087 ± 1132.673 ops/ms
TestTableNameJMH.testStr10000 thrpt 10 9231.439 ± 2480.242 ops/ms
TestTableNameJMH.testStr100000 thrpt 10 7458.192 ± 1046.736 ops/ms
Benchmark Result For String:
Benchmark Mode Cnt Score Error Units
TestTableNameJMH.testBB1 thrpt 10 20719.730 ± 987.327 ops/ms
TestTableNameJMH.testBB10 thrpt 10 20698.180 ± 240.704 ops/ms
TestTableNameJMH.testBB100 thrpt 10 19331.825 ± 232.413 ops/ms
TestTableNameJMH.testBB1000 thrpt 10 18865.971 ± 260.727 ops/ms
TestTableNameJMH.testBB10000 thrpt 10 13420.776 ± 1473.567 ops/ms
TestTableNameJMH.testBB100000 thrpt 10 7209.563 ± 2928.791 ops/ms
TestTableNameJMH.testStr1 thrpt 10 133099.686 ± 5902.544 ops/ms
TestTableNameJMH.testStr10 thrpt 10 141280.563 ± 7157.877 ops/ms
TestTableNameJMH.testStr100 thrpt 10 127057.065 ± 11665.471 ops/ms
TestTableNameJMH.testStr1000 thrpt 10 85985.687 ± 18432.481 ops/ms
TestTableNameJMH.testStr10000 thrpt 10 51825.915 ± 1824.001 ops/ms
TestTableNameJMH.testStr100000 thrpt 10 19002.112 ± 3337.013 ops/ms
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org