lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eyal Post (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENENET-181) Port of ThreadLocal is wrong?
Date Mon, 20 Apr 2009 07:58:47 GMT

    [ 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.


Mime
View raw message