groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serega Sheypak <serega.shey...@gmail.com>
Subject Re: Optimizing groovy performace
Date Fri, 15 Apr 2016 18:33:18 GMT
I'm using 2.4.4 Indy
Storm Framework design is thread safe.
Each thread has its own hash map. This factory is not shared across
concurrent threads.

пятница, 15 апреля 2016 г. пользователь John Wagenleitner написал:

> Which version of Groovy are you using?  I believe in 2.4.6 there was a
> minor change in the invalidateCallSites for synchronization, probably not
> the issue here but would be curious to know if also a problem on other
> version.
>
> Looking your gist for ScriptFactory I notice you use a HashMap.  I think
> you mentioned that this app is highly concurrent, so I would recommend
> using a static final ConcurrentHashMap.
>
> On Thu, Apr 14, 2016 at 2:58 PM, Serega Sheypak <serega.sheypak@gmail.com
> <javascript:_e(%7B%7D,'cvml','serega.sheypak@gmail.com');>> wrote:
>
>> Here is the screenshot from VisualVM.
>> [image: Встроенное изображение 1]
>>
>> 2016-04-14 23:49 GMT+02:00 Serega Sheypak <serega.sheypak@gmail.com
>> <javascript:_e(%7B%7D,'cvml','serega.sheypak@gmail.com');>>:
>>
>>> Bump
>>>
>>> 2016-04-12 11:19 GMT+02:00 Serega Sheypak <serega.sheypak@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','serega.sheypak@gmail.com');>>:
>>>
>>>> Hi, any update here? Could you give me some input for further
>>>> investigation?
>>>>
>>>> 2016-04-11 12:58 GMT+02:00 Serega Sheypak <serega.sheypak@gmail.com
>>>> <javascript:_e(%7B%7D,'cvml','serega.sheypak@gmail.com');>>:
>>>>
>>>>> *>you wrote there are 20 such replacement cases... executing 20
>>>>> scripts is hardly a problem, so it must happen in a loop...*
>>>>> Sorry, didn't understand, what do you mean by loop?
>>>>>
>>>>> *>do you reuse the scripts, or do you make a new script each time?
*
>>>>> I suppose I do reuse, please have a look at "ScriptFactory"
>>>>>
>>>>> *Hi, here is naive caching factory:*
>>>>> https://gist.github.com/seregasheypak/2d7f5a16fa31018c8212754c8e94f9a4
>>>>>
>>>>> *>To give an advice I have to understand your setup better first*
>>>>> I run http://storm.apache.org/ topology.
>>>>> If you are not familiar with it, assume I have a running thread-safe
>>>>> java application. Java application keeps 1000 User objects and 20
>>>>> GroovyScripts in memory.
>>>>> I run 1000 (users) *20 (script: def evaluateExpression(Map context))
>>>>> executions each second.
>>>>> If script for User object returns true, I do something special.
>>>>>
>>>>> I try to cache script instances (see my gist).
>>>>> User object is just a bean with some logic incapsulated.
>>>>>
>>>>> 2016-04-11 11:30 GMT+02:00 Jochen Theodorou <blackdrag@gmx.org
>>>>> <javascript:_e(%7B%7D,'cvml','blackdrag@gmx.org');>>:
>>>>>
>>>>>> On 10.04.2016 20:52, Serega Sheypak wrote:
>>>>>>
>>>>>>>  >
>>>>>>> org.codehaus.groovy.vmplugin.v7.Selector$MethodSelector.doCallSiteTargetSet
>>>>>>> I see this method after switching to indy version with invkoedynamic
>>>>>>>
>>>>>>>  That is a hint, that you have a lot of invalid callsites going
on
>>>>>>>>
>>>>>>> What does it mean? What can I do in order fix it?
>>>>>>>
>>>>>>> Those are all strings?
>>>>>>>>
>>>>>>> Script template is:
>>>>>>>
>>>>>>> |defevaluateExpression(Mapcontext){defuser =context.user %s }|
>>>>>>>
>>>>>>> dynamically substituted expression could contain anything
>>>>>>>
>>>>>>> |user.attr1 =='1'||user.attr2 =='2'||user.attr3 ='3'|
>>>>>>>
>>>>>>> user object holds info about a user doing something online. attr1,
>>>>>>> attr2, attr3 could returns various types. Sometimes they return
>>>>>>> object
>>>>>>> and I override returned object equals method.
>>>>>>>
>>>>>>
>>>>>> you wrote there are 20 such replacement cases... executing 20 scripts
>>>>>> is hardly a problem, so it must happen in a loop... do you reuse
the
>>>>>> scripts, or do you make a new script each time? Because if you do
them new
>>>>>> each time, you have of course never ever an caching going on... but
then
>>>>>> the compiler should appear in your measurement as bad factor as well
>>>>>> actually.
>>>>>>
>>>>>> To give an advice I have to understand your setup better first
>>>>>>
>>>>>>
>>>>>> For example, 'user' object has method:
>>>>>>> LastPage getLastPage(){
>>>>>>>          def attr = getLatestAttribute(PAGE)
>>>>>>>          if(attr){
>>>>>>>              lastPage = attr.value
>>>>>>>          }
>>>>>>>          new LastPage(lastPage: lastPage)
>>>>>>>      }
>>>>>>>
>>>>>>> then you can write expression:
>>>>>>> user.lastPage == 'somePageRegEx/.*' when you want to get true
if user
>>>>>>> last page mathes provided regex.
>>>>>>>
>>>>>>> Here is LastPage impl:
>>>>>>> class LastPage {
>>>>>>>      String lastPage
>>>>>>>
>>>>>>>      @Override
>>>>>>>      String toString(){
>>>>>>>          lastPage
>>>>>>>      }
>>>>>>>
>>>>>>>      @Override
>>>>>>>      int hashCode(){
>>>>>>>          1
>>>>>>>      }
>>>>>>>
>>>>>>>      @Override
>>>>>>>      boolean equals(Object object){
>>>>>>>          if(object == null || !(object instanceof String || object
>>>>>>> instanceof LastPage)){
>>>>>>>              return false
>>>>>>>          }
>>>>>>>          if(object instanceof LastPage){
>>>>>>>              lastPage.equals(object.lastPage)
>>>>>>>          }
>>>>>>>          else{
>>>>>>>              Pattern pattern = Pattern.compile((String)object)
>>>>>>>              lastPage ==~ pattern
>>>>>>>          }
>>>>>>>      }
>>>>>>> }
>>>>>>>
>>>>>>
>>>>>> and pattern compilation here does not have a negative factor in your
>>>>>> measurement?
>>>>>>
>>>>>> bye Jochen
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

Mime
View raw message