From lucene-net-dev-return-1966-apmail-incubator-lucene-net-dev-archive=incubator.apache.org@incubator.apache.org Mon Apr 20 07:59:15 2009 Return-Path: Delivered-To: apmail-incubator-lucene-net-dev-archive@minotaur.apache.org Received: (qmail 31540 invoked from network); 20 Apr 2009 07:59:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Apr 2009 07:59:14 -0000 Received: (qmail 80771 invoked by uid 500); 20 Apr 2009 07:59:14 -0000 Delivered-To: apmail-incubator-lucene-net-dev-archive@incubator.apache.org Received: (qmail 80748 invoked by uid 500); 20 Apr 2009 07:59:14 -0000 Mailing-List: contact lucene-net-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@incubator.apache.org Delivered-To: mailing list lucene-net-dev@incubator.apache.org Received: (qmail 80738 invoked by uid 99); 20 Apr 2009 07:59:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 07:59:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 07:59:07 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6CDB2234C004 for ; Mon, 20 Apr 2009 00:58:47 -0700 (PDT) Message-ID: <29907038.1240214327441.JavaMail.jira@brutus> Date: Mon, 20 Apr 2009 00:58:47 -0700 (PDT) From: "Eyal Post (JIRA)" To: lucene-net-dev@incubator.apache.org Subject: [jira] Commented: (LUCENENET-181) Port of ThreadLocal is wrong? In-Reply-To: <98966893.1240167587455.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENENET-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12700688#action_12700688 ] Eyal Post commented on LUCENENET-181: ------------------------------------- {quote} One term-cache per thread is what is intended in Java (or I think so). {quote} No It's not. Here are the reasons: 1. If that's what they intended then they would have made enumerators static. 2. There can be many instances of TermInfosReader in a process each needing a *different* termEnum. It's doesn't make sense for them to use the same enum instance becuase an enum should be created *per TermInfosReader*. {quote} As I wanted to show in "TestCase", if you make "enumerators" static, cache is created only once per thread, otherwise it is created with every new instance of TermInfosReader {quote} Which is exactly how it should work. {quote} ( A private field would be enough for that type of cache). {quote} A private field would *not* be enough becuase multiple threads using the same TermInfosReader will get the same enumerator each stepping on the other's toe. That is exactly what ThreadLocal is preventing. > Port of ThreadLocal is wrong? > ----------------------------- > > Key: LUCENENET-181 > URL: https://issues.apache.org/jira/browse/LUCENENET-181 > Project: Lucene.Net > Issue Type: Improvement > Reporter: Digy > Priority: Minor > Attachments: TestCase.cs > > > AFAIK, "ThreadLocal" in Java is there to hold objects which are intented to be used thread-wide. So, its port-equivalent "LocalDataStoreSlot" should contain objects related with the executing thread. But, since they are not declared as "static" in Analyzer.cs, FieldsReader.cs, SegmentReader.cs and TermInfosReader.cs, they are created with every class contruction, changing the behaviour of "ThreadLocal" and possibly resulting in performance degradation. > I will attach a test case for this issue. > If I am wrong, then there is no problem. But If I am right we are in trouble; Since adding "static" to variables declared as LocalDataStoreSlot results in failing of almost all test cases. > DIGY -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.