[
https://issues.apache.org/jira/browse/FELIX-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519960
]
Karl Pauls commented on FELIX-338:
----------------------------------
Well, in my experience it never pays to jump to conclusions when Java
is involved. I actually wrote a quick test and see the following
(Apple, JVM 1.3 and 1.5).
syncing the match method adds ~ 5% overhead in a single thread scenario.
syncing the match method adds ~ 40% overhead in a multi thread scenario.
creating new instances adds ~ 40 % overhead in a single thread scenario.
creating new instances adds ~ 40 % overhead in a multi thread scenario.
In other words, the new instances approach doesn't seem that good to
me (your mileage may vary :-).
Fortunately, I wrote a solution that uses a ThreadLocal to only create
a new instance per Thread. I keep the instance in a SoftReference and
for my test the memory looks good to. This solution gives me:
ThreadLocal adds ~ 5% overhead in a single thread scenario
ThreadLocal adds ~ 5% overhead in a multi thread scenario
The downside is that it doesn't necessarily makes the code more pretty ;-).
> Framework FilterImpl is not thread safe on execution
> ----------------------------------------------------
>
> Key: FELIX-338
> URL: https://issues.apache.org/jira/browse/FELIX-338
> Project: Felix
> Issue Type: Bug
> Components: Framework
> Affects Versions: 0.8.0, 1.0.0
> Reporter: Felix Meschberger
>
> Executing a Filter implemented by the Felix Framework FilterImpl class is not
> thread safe, as the Filter.Implmatch() methods are not synchronized but use a
> Mapper and Evaluator instance fields which are modified while matching the
> filter.
> Two options seem to exist:
> 1. Make the match() methods synchronized
> 2. Create Mapper and Evaluator instances on each match() call
> My assumption is that the second method tends to be better because of the
> synchronization needed with the first approach.
> Reported by Tom Remoleur, thanks. The full mail thread leading to this issue
> may be found at [1].
> [1] http://www.mail-archive.com/[EMAIL PROTECTED]/msg00145.html
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.