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 A6965200C2B for ; Thu, 2 Mar 2017 16:57:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A5281160B7A; Thu, 2 Mar 2017 15:57:49 +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 EF82B160B61 for ; Thu, 2 Mar 2017 16:57:48 +0100 (CET) Received: (qmail 4627 invoked by uid 500); 2 Mar 2017 15:57:48 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 4616 invoked by uid 99); 2 Mar 2017 15:57:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Mar 2017 15:57:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 90A5BC108E for ; Thu, 2 Mar 2017 15:57:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.451 X-Spam-Level: * X-Spam-Status: No, score=1.451 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id XVWekSJ6anSb for ; Thu, 2 Mar 2017 15:57:46 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 452B55FB62 for ; Thu, 2 Mar 2017 15:57:46 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 81DDAE0599 for ; Thu, 2 Mar 2017 15:57:45 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 39E1424156 for ; Thu, 2 Mar 2017 15:57:45 +0000 (UTC) Date: Thu, 2 Mar 2017 15:57:45 +0000 (UTC) From: "Benjamin Papez (JIRA)" To: dev@jackrabbit.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JCR-4116) SharedItemStateManager.getNonVirtualItemState is over-synchronized MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 02 Mar 2017 15:57:49 -0000 [ https://issues.apache.org/jira/browse/JCR-4116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15892453#comment-15892453 ] Benjamin Papez commented on JCR-4116: ------------------------------------- Thanks once more. So at least there cannot be an inconsistency. Still it looks like the synchronization is quite a bottleneck here. In a thread-dump I looked at today 246 threads are within {{getNonVirtualItemState}}: 229 threads are waiting in {{synchronized (this)}}, 16 threads are on the {{wait()}} and 1 thread is in {{notifyAll}} > SharedItemStateManager.getNonVirtualItemState is over-synchronized > ------------------------------------------------------------------ > > Key: JCR-4116 > URL: https://issues.apache.org/jira/browse/JCR-4116 > Project: Jackrabbit Content Repository > Issue Type: Bug > Components: jackrabbit-core > Affects Versions: 2.10.5, 2.12.6, 2.15.0, 2.13.7, 2.14.0, 2.8.5 > Reporter: Benjamin Papez > > With JCR-2813 and revision 1038201 bigger synchronization has been removed, but I think it is still too big. > {code} > // Wait if another thread is already loading this item state > synchronized (this) { > while (currentlyLoading.contains(id)) { > try { > wait(); > } catch (InterruptedException e) { > throw new ItemStateException( > "Interrupted while waiting for " + id, e); > } > } > state = cache.retrieve(id); > if (state != null) { > return state; > } > // No other thread has loaded the item state, so we'll do it > currentlyLoading.add(id); > } > {code} > Looking at thread dumps I see that the reality does not match the comment {{Wait if another thread is already loading this item state}}, because threads have to wait even if they want a different item state. > If one thread goes into the wait() method it locks all other threads out, which use the same SharedItemsStateManager instance, because of the {{synchronized (this)}}. > I think that it would be better if {{currentlyLoading}} would be backed by a thread-safe {{CoincurrentHashMap}}, so {{synchronized (this)}} would not be necessary around {{currentlyLoading.contains}}. -- This message was sent by Atlassian JIRA (v6.3.15#6346)