Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 70432200BEF for ; Wed, 21 Dec 2016 02:34:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6ECEA160B33; Wed, 21 Dec 2016 01:34:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6091C160B29 for ; Wed, 21 Dec 2016 02:33:59 +0100 (CET) Received: (qmail 39827 invoked by uid 500); 21 Dec 2016 01:33:58 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 39816 invoked by uid 99); 21 Dec 2016 01:33:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2016 01:33:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 5C5452C2A66 for ; Wed, 21 Dec 2016 01:33:58 +0000 (UTC) Date: Wed, 21 Dec 2016 01:33:58 +0000 (UTC) From: "ChiaPing Tsai (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HBASE-17331) Avoid busy waiting in ThrottledInputStream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 21 Dec 2016 01:34:00 -0000 [ https://issues.apache.org/jira/browse/HBASE-17331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] ChiaPing Tsai updated HBASE-17331: ---------------------------------- Release Note: For each read(), old ThrottledInputStream sleeps/wakes/checks for many times for controlling the throughput. After this patch, ThrottledInputStream sleeps/wakes/checks only once. So we can reduce CPU usage. > Avoid busy waiting in ThrottledInputStream > ------------------------------------------ > > Key: HBASE-17331 > URL: https://issues.apache.org/jira/browse/HBASE-17331 > Project: HBase > Issue Type: Improvement > Affects Versions: 2.0.0 > Reporter: ChiaPing Tsai > Assignee: ChiaPing Tsai > Priority: Minor > Fix For: 2.0.0 > > Attachments: HBASE-17331.addendum.patch, HBASE-17331.v0.patch, HBASE-17331.v1.patch, HBASE-17331.v2.patch, HBASE-17331.v2.patch > > > {code:title=ThrottledInputStream.java|borderStyle=solid} > // We can calculate the precise sleep time instead of busy waiting > private void throttle() throws IOException { > while (getBytesPerSec() > maxBytesPerSec) { > try { > Thread.sleep(SLEEP_DURATION_MS); > totalSleepTime += SLEEP_DURATION_MS; > } catch (InterruptedException e) { > throw new IOException("Thread aborted", e); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)