Return-Path: X-Original-To: apmail-accumulo-dev-archive@www.apache.org Delivered-To: apmail-accumulo-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5ADBD19186 for ; Tue, 1 Mar 2016 22:17:59 +0000 (UTC) Received: (qmail 61050 invoked by uid 500); 1 Mar 2016 22:17:59 -0000 Delivered-To: apmail-accumulo-dev-archive@accumulo.apache.org Received: (qmail 61002 invoked by uid 500); 1 Mar 2016 22:17:59 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 60991 invoked by uid 99); 1 Mar 2016 22:17:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Mar 2016 22:17:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CF7B1DFCF2; Tue, 1 Mar 2016 22:17:58 +0000 (UTC) From: keith-turner To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request: ACCUMULO-1755: Modified TSBW so that all cl... Content-Type: text/plain Message-Id: <20160301221758.CF7B1DFCF2@git1-us-west.apache.org> Date: Tue, 1 Mar 2016 22:17:58 +0000 (UTC) Github user keith-turner commented on a diff in the pull request: https://github.com/apache/accumulo/pull/75#discussion_r54645749 --- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java --- @@ -427,11 +437,11 @@ public void updateBinningStats(int count, long time, Map> binnedMutations) { - tabletServersBatchSum += binnedMutations.size(); + private void updateBatchStats(Map> binnedMutations) { + tabletServersBatchSum.addAndGet(binnedMutations.size()); - minTabletServersBatch = Math.min(minTabletServersBatch, binnedMutations.size()); - maxTabletServersBatch = Math.max(maxTabletServersBatch, binnedMutations.size()); + minTabletServersBatch.set(Math.min(minTabletServersBatch.get(), binnedMutations.size())); + maxTabletServersBatch.set(Math.max(maxTabletServersBatch.get(), binnedMutations.size())); --- End diff -- This method of updating has a race condition. Multiple threads could call get() before calling set(). Also all of these atomic vars require round trips to main memory (not sure how much this matters). I can think of two possible solutions. Both involve creating a BatchWriterStats class to make the code more managable. 1. Could add a syncrhonized updateBatchStats method to BatchWriterStats. No longer syncing on main lock or making lots of trips to main mem. 2. Could have an AtomicRef. To update batch writer stats read the ref, clone it, make updates to clone, update ref using CAS to ensure ref has not changed. If ref changed, then start over. This avoids lock, race conditions, and lots of trips to main memory. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---