You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Andrei Badea (JIRA)" <ji...@apache.org> on 2013/01/11 17:32:13 UTC
[jira] [Updated] (WICKET-4971) AtmosphereEventSubscriptionCollector
is slow
[ https://issues.apache.org/jira/browse/WICKET-4971?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrei Badea updated WICKET-4971:
---------------------------------
Description:
AtmosphereEventSubscriptionCollector.onBeforeRender() is called so often that the amount of work it performs starts being significant. The method was a hotspot in our performance tests. I reduced the average HTTP response time by 20ms by caching the subscribe metods:
private static final ConcurrentMap<Class<?>, List<Method>> class2SubscribeMethod = new ConcurrentHashMap<Class<?>, List<Method>>();
@Override
public void onBeforeRender(Component component)
{
for (Method curMethod : getSubscribeMethods(component.getClass()))
{
subscribeComponent(component, null, curMethod);
}
for (Behavior curBehavior : component.getBehaviors())
{
for (Method curMethod : getSubscribeMethods(curBehavior.getClass()))
{
subscribeComponent(component, curBehavior, curMethod);
}
}
}
private List<Method> getSubscribeMethods(Class<?> clazz)
{
List<Method> methods = class2SubscribeMethod.get(clazz);
if (methods != null)
{
return methods;
}
methods = computeSubscribeMethods(clazz);
List<Method> newMethods = class2SubscribeMethod.putIfAbsent(clazz, methods);
return newMethods != null ? newMethods : methods;
}
private List<Method> computeSubscribeMethods(Class<?> clazz)
{
List<Method> result = Lists.newArrayList();
for (Method curMethod : clazz.getMethods())
{
if (curMethod.isAnnotationPresent(Subscribe.class))
{
verifyMethodParameters(curMethod);
result.add(curMethod);
}
}
return result;
}
I can provide a patch of a pull request if needed.
was:
AtmosphereEventSubscriptionCollector.onBeforeRender() is called so often that the amount of work it performs starts being significant. The method was a hotspot in our performance tests. I was reduced the average HTTP response time by 20ms by caching the subscribe metods:
private static final ConcurrentMap<Class<?>, List<Method>> class2SubscribeMethod = new ConcurrentHashMap<Class<?>, List<Method>>();
@Override
public void onBeforeRender(Component component)
{
for (Method curMethod : getSubscribeMethods(component.getClass()))
{
subscribeComponent(component, null, curMethod);
}
for (Behavior curBehavior : component.getBehaviors())
{
for (Method curMethod : getSubscribeMethods(curBehavior.getClass()))
{
subscribeComponent(component, curBehavior, curMethod);
}
}
}
private List<Method> getSubscribeMethods(Class<?> clazz)
{
List<Method> methods = class2SubscribeMethod.get(clazz);
if (methods != null)
{
return methods;
}
methods = computeSubscribeMethods(clazz);
List<Method> newMethods = class2SubscribeMethod.putIfAbsent(clazz, methods);
return newMethods != null ? newMethods : methods;
}
private List<Method> computeSubscribeMethods(Class<?> clazz)
{
List<Method> result = Lists.newArrayList();
for (Method curMethod : clazz.getMethods())
{
if (curMethod.isAnnotationPresent(Subscribe.class))
{
verifyMethodParameters(curMethod);
result.add(curMethod);
}
}
return result;
}
I can provide a patch of a pull request if needed.
> AtmosphereEventSubscriptionCollector is slow
> --------------------------------------------
>
> Key: WICKET-4971
> URL: https://issues.apache.org/jira/browse/WICKET-4971
> Project: Wicket
> Issue Type: Bug
> Components: wicket-atmosphere
> Reporter: Andrei Badea
> Assignee: Emond Papegaaij
>
> AtmosphereEventSubscriptionCollector.onBeforeRender() is called so often that the amount of work it performs starts being significant. The method was a hotspot in our performance tests. I reduced the average HTTP response time by 20ms by caching the subscribe metods:
> private static final ConcurrentMap<Class<?>, List<Method>> class2SubscribeMethod = new ConcurrentHashMap<Class<?>, List<Method>>();
> @Override
> public void onBeforeRender(Component component)
> {
> for (Method curMethod : getSubscribeMethods(component.getClass()))
> {
> subscribeComponent(component, null, curMethod);
> }
> for (Behavior curBehavior : component.getBehaviors())
> {
> for (Method curMethod : getSubscribeMethods(curBehavior.getClass()))
> {
> subscribeComponent(component, curBehavior, curMethod);
> }
> }
> }
> private List<Method> getSubscribeMethods(Class<?> clazz)
> {
> List<Method> methods = class2SubscribeMethod.get(clazz);
> if (methods != null)
> {
> return methods;
> }
> methods = computeSubscribeMethods(clazz);
> List<Method> newMethods = class2SubscribeMethod.putIfAbsent(clazz, methods);
> return newMethods != null ? newMethods : methods;
> }
> private List<Method> computeSubscribeMethods(Class<?> clazz)
> {
> List<Method> result = Lists.newArrayList();
> for (Method curMethod : clazz.getMethods())
> {
> if (curMethod.isAnnotationPresent(Subscribe.class))
> {
> verifyMethodParameters(curMethod);
> result.add(curMethod);
> }
> }
> return result;
> }
> I can provide a patch of a pull request if needed.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira