[Javassist Development] New message: "Re: ScopedClassPoolRepositoryImpl and default ClassPool"
by Flavia Rainone
JBoss development,
A new message was posted in the thread "ScopedClassPoolRepositoryImpl and default ClassPool":
http://community.jboss.org/message/527262#527262
Author : Flavia Rainone
Profile : http://community.jboss.org/people/flavia.rainone@jboss.com
Message:
--------------------------------------------------------------
On a private talk with Kabir and Ales, we decided that the best thing to do for now is to copy those ScopedCP classes to a new module of jboss-classpool project and "fix" everything that is getting in the way with those.
As Kabir mentioned, those ScopedCP classes were created by us to be used inside AS. Now, they are outdated since they won't work in AS and we ended up needing ve a project only for that.
I'm calling that new module scoped-classpool. Once it is ready, we can decide whether it would be a good idea to use those changes as a patch for Javassist, or whether we wanna keep it the way it is.
I have only one observation to do regarding this. It will add a dependency from jboss-reflect towards scoped-classpool module. The way we are today, we have all references to the ScopedCP classes, and no reference at all to the subclasses in jboss-classpool project. Plus, we will also have to edit several references to ScopedCP's in JBoss AOP project as well.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527262#527262
16 years, 1 month
[JBoss AOP Development] New message: "Re: ClassPool Refactoring"
by Flavia Rainone
JBoss development,
A new message was posted in the thread "ClassPool Refactoring":
http://community.jboss.org/message/527258#527258
Author : Flavia Rainone
Profile : http://community.jboss.org/people/flavia.rainone@jboss.com
Message:
--------------------------------------------------------------
> mailto:flavia.rainone@jboss.com wrote:
>
> All tests are passing now in my system, which allowed me to validate two previous fixes Kabir and I implemented for the problem of duplicate CtClasses.
> Kabir's fix consists of https://jira.jboss.org/jira/browse/JBAOP-766 :
>
> *public* *class* DelegatingClassPool *extends* BaseClassPool
> {
> ...
> *public* CtClass getCached(String classname)
> {
> >>> //TODO Not 100 sure this is correct, but it seems to do the job where repeated calls to get() on a pool in a hierarchy returns a different instance of the class
> >>> CtClass clazz = super.getCachedLocally(classname);
> >>> *if* (clazz != *null*)
> >>> *return* clazz;
>
> *if* (isGeneratedClass(classname))
> {
> *return* *null*;
> }
> *return* domain.getCachedOrCreate(this, classname, *false*);
> }
> }
>
>
>
>
>
>
> My fix has never been comitted and consists of adding a check on the classes cache to BaseClassPool.get:
>
>
>
> *public* *class* BaseClassPool *extends* AbstractClassPool
> {
> ...
> @Override
> *public* *final* CtClass get(String classname) *throws* NotFoundException
> {
> *boolean* trace = logger.isTraceEnabled();
> *if* (trace) logger.trace(*this* + " initiating get of " + classname);
>
> *if* (this.getClassLoader() == *null*)
> {
> *throw* *new* IllegalStateException("Illegal call. " + " A class cannot be retrieved from ClassPool " +
> *this* + " because the corresponding ClassLoader is garbage collected");
> }
> *try*
> {
> >>> *if* (this.classes.containsKey(classname))
> >>> {
> >>> *return* (CtClass) classes.get(classname);
> >>> }
> CtClass clazz = super.get(classname);
> *if* (trace)
> logger.trace(*this* + " completed get of " + classname + " " + getClassPoolLogStringForClass(clazz));
>
> *return* clazz;
> }
> *catch* (NotFoundException e)
> {
> *if* (trace)
> logger.trace(classname + " could not be found from " + this, e);
> *throw* e;
> }
> }
> }
>
>
>
>
>
> It turns out that, once all tests were fixed for issue https://jira.jboss.org/jira/browse/JBREFLECT-94, those fixes weren't needed anymore, which means that JBREFLECT-94 was the real issue.
>
>
>
> Now I'm left with the dillema of whether should I commit those fixes. I have started running some tests to try to figure out if any of those bring some improvement, and it seems that looking up classes cache in BaseClassLoader.get does bring a few improvements to the performance of aop tests, but I need to run those tests more times in order to do a reasonable investigation.
>
>
>
> While working with Kabir to fix the AOP tests for AS, he pointed out that there could be an issue related to my fix. It seemed obviously right to me to look in the classes cache (a cache declared in ScopedClassPool that contains all classes created by the current class pool) before doing anything else. To me, if we have a hit in the cache, it means that the current pool is the one that is supposed to load the class, and that there is no need to look further by calling super.get method. But Kabir raised the following possibility. What if the class pool scenario (a reflection of the class loader/domain scenario) changes after the current class pool loaded the class, in a way that this class pool is no longer the one responsible for loading that class? In that case, looking for the class in the classes cache would be a serious mistake. Is this scenario possible?
>
> Regarding Kabir's fix, I'm also looking for any opnion regarding whether it should be committed. It seems, though, that adding both fixes brings some small performance penalty. I'll continue running tests to be able to assert whether this is really true, and what is the penalty we're talking about.
I ran the performance tests, and concluded that there is not performance penalty in including both "fixes". On the contrary, I have seen some small improvements with those (AOPUnitTestCase runs 2.5 seconds faster with the fix on BaseClassPool; as starts 200 ms faster in all mode with both fixes).
I'm comitting this.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527258#527258
16 years, 1 month
[JBoss Microcontainer Development] New message: "Re: Profiling the dependency project"
by Kabir Khan
JBoss development,
A new message was posted in the thread "Profiling the dependency project":
http://community.jboss.org/message/527247#527247
Author : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com
Message:
--------------------------------------------------------------
Since installCallbacks and uninstallCallbacks are ConcurrentHashMaps, I think the read lock is unnecessary here in AbstractController:
===================================================================
--- src/main/java/org/jboss/dependency/plugins/AbstractController.java (revision 100970)
+++ src/main/java/org/jboss/dependency/plugins/AbstractController.java (working copy)
@@ -1833,17 +1833,9 @@
*/
protected Set<CallbackItem<?>> getCallbacks(Object name, boolean isInstallPhase)
{
- lockRead();
- try
- {
- Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
- Set<CallbackItem<?>> callbacks = map.get(name);
- return callbacks != null ? callbacks : Collections.<CallbackItem<?>>emptySet();
- }
- finally
- {
- unlockRead();
- }
+ Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+ Set<CallbackItem<?>> callbacks = map.get(name);
+ return callbacks != null ? callbacks : Collections.<CallbackItem<?>>emptySet();
}
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527247#527247
16 years, 1 month
[JBoss Microcontainer Development] New message: "Re: Profiling the kernel project"
by Kabir Khan
JBoss development,
A new message was posted in the thread "Profiling the kernel project":
http://community.jboss.org/message/527084#527084
Author : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com
Message:
--------------------------------------------------------------
Changing CommonAnnotationAdapter to not always create iterators improves things a little bit:
e.g. things like
ClassInfo classInfo = info.getClassInfo();
- for (Annotation annotation : retrieval.getAnnotations())
+ Annotation[] anns = retrieval.getAnnotations();
+ for (int i = 0 ; i < anns.length ; i++)
{
- for(T plugin : getPlugins(ElementType.TYPE, annotation, null, annotationClasses))
+ for(T plugin : getPlugins(ElementType.TYPE, anns[i], null, annotationClasses))
{
if (isApplyPhase)
- applyPlugin(plugin, annotation, classInfo, retrieval, handle);
+ applyPlugin(plugin, anns[i], classInfo, retrieval, handle);
else
- cleanPlugin(plugin, annotation, classInfo, retrieval, handle);
+ cleanPlugin(plugin, anns[i], classInfo, retrieval, handle);
}
}
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527084#527084
16 years, 1 month