[
https://issues.apache.org/jira/browse/HBASE-8329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14258087#comment-14258087
]
zhangduo commented on HBASE-8329:
---------------------------------
add a testcase to test compaction speed locally.
The result is
{noformat}
Test with rowSize = 16 B, size = 358.29 MB, duration = 8802ms, rate =
41682.69917792121KB/sec
Test with rowSize = 4 KB, size = 1.21 GB, duration = 25054ms, rate =
50831.594965811346KB/sec
Test with rowSize = 512 KB, size = 1.25 GB, duration = 32501ms, rate =
40347.30749270215KB/sec
{noformat}
Seems even with a small value size we can still get a 40MB/sec rate...
{code:title=TestCompactionSpeed.java}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.regionserver.compactions;
import java.io.IOException;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.common.hash.Hashing;
public class TestCompactionSpeed {
private static final Log LOG = LogFactory.getLog(TestCompactionSpeed.class);
private HBaseTestingUtility util = new HBaseTestingUtility();
private byte[] tableName = TableName.valueOf(getClass().getSimpleName(),
"test").getName();
private byte[] family = Bytes.toBytes("f");
private byte[] qualifier = Bytes.toBytes("q");
private HRegion region;
@Before
public void setUp() throws IOException {
util.getConfiguration().setLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE,
1024L * 1024 * 1024);
util.getConfiguration().setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MIN_KEY,
20);
util.getConfiguration().setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
40);
region =
util.createLocalHRegion(tableName, null, null, "",
util.getConfiguration(), false,
Durability.SKIP_WAL, null, family);
}
@After
public void tearDown() throws IOException {
region.close();
util.cleanupTestDir();
}
private void prepareData(int rowSize, long flushSize, int storeFileCount)
throws IOException {
long rowCount = 0;
byte[] value = new byte[rowSize];
for (int i = 0; i < storeFileCount; i++) {
while (region.memstoreSize.get() < flushSize) {
ThreadLocalRandom.current().nextBytes(value);
Put put =
new Put(Hashing.murmur3_32().hashLong(rowCount).asBytes())
.add(family, qualifier, value);
region.put(put);
rowCount++;
}
region.flushcache(true);
}
}
private void testCompactionSpeed(int rowSize) throws IOException {
prepareData(rowSize, 128L * 1024 * 1024, 10);
long size = region.getStore(family).getStorefilesSize();
long startTime = System.currentTimeMillis();
region.compactStores(true);
long duration = System.currentTimeMillis() - startTime;
LOG.info("Test with rowSize = " + StringUtils.byteDesc(rowSize) + ", size =
"
+ StringUtils.byteDesc(size) + ", duration = " + duration + "ms" + ",
rate = "
+ ((double) size / duration * 1000 / 1024) + "KB/sec");
}
@Test
public void testSmall() throws IOException {
testCompactionSpeed(16);
}
@Test
public void testMedium() throws IOException {
testCompactionSpeed(4 * 1024);
}
@Test
public void testLarge() throws IOException {
testCompactionSpeed(512 * 1024);
}
}
{code}
> Limit compaction speed
> ----------------------
>
> Key: HBASE-8329
> URL: https://issues.apache.org/jira/browse/HBASE-8329
> Project: HBase
> Issue Type: Improvement
> Components: Compaction
> Reporter: binlijin
> Assignee: Sergey Shelukhin
> Fix For: 2.0.0, 1.1.0
>
> Attachments: HBASE-8329-10.patch, HBASE-8329-11.patch,
> HBASE-8329-12.patch, HBASE-8329-2-trunk.patch, HBASE-8329-3-trunk.patch,
> HBASE-8329-4-trunk.patch, HBASE-8329-5-trunk.patch, HBASE-8329-6-trunk.patch,
> HBASE-8329-7-trunk.patch, HBASE-8329-8-trunk.patch, HBASE-8329-9-trunk.patch,
> HBASE-8329-trunk.patch
>
>
> There is no speed or resource limit for compaction,I think we should add this
> feature especially when request burst.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)