-
1. Re: optimizing introspection/reflection
heiko.braun Jun 28, 2006 11:30 AM (in response to aloubyansky)Previously (using XercesXSMarshaller) the reflection wrapper have been cached in the MappinObjectModelProvider. This could eagerly be populated and reused throughout several Marshaller invocations. Especially the WS usecases did benefit from this, because otherwise the same classes would have been introspected over and over again.
When optimizing XB regarding the use of the reflection API, wouldn't it makes sense to extend the API that the callee could actually provide that mapping model, similar to what has been possible with the MappinObjectModelProvider?
IMO usecases that work on the same object model /schema would greatly benefit in terms of performance. -
2. Re: optimizing introspection/reflection
aloubyansky Jun 28, 2006 12:07 PM (in response to aloubyansky)Probably, you are right. But before going that way let's make sure we are not leaving behind more critical performance issues that should be addressed first. Why don't we come up with a series of most common use-cases (probably, you already have them), run the tests and identify the bottlenecks and their severity?
-
3. Re: optimizing introspection/reflection
bill.burke Jun 28, 2006 12:16 PM (in response to aloubyansky)the biggest performance improvement would be the ability to serialize schema models to disk so that the XML wouldn't have to be parsed for the schema. A profiling run of E-EJB3 showed that schema parsing took 10% of boottime.
-
4. Re: optimizing introspection/reflection
aloubyansky Jun 28, 2006 12:40 PM (in response to aloubyansky)That's true. However, for the next release I am just gonna do what the WS guys want...
In fact that may help them too. But I'll let them to decide. -
5. Re: optimizing introspection/reflection
heiko.braun Jun 29, 2006 5:05 AM (in response to aloubyansky)Well, after the last improvement (LinkedList->ArrayList), it became evident that creating the reflection wrapper (getter, setter, field access) is the biggest bottleneck. I did some quick prototype, similiar to what you did with ClassInfo and FieldInfo and it turned out that performance increased significantly.
IMO you are on the right way. Although i would suggest to cache this information per Marshaller/Unmarshaller instance and not statically/globally. This way we can additional synchronisation and it would still be possible for the callee to reuse particular instances per usecase. -
6. Re: optimizing introspection/reflection
heiko.braun Jun 29, 2006 5:06 AM (in response to aloubyansky)This way we can avoid additional synchronisation...
-
7. Re: optimizing introspection/reflection
heiko.braun Jul 4, 2006 3:30 AM (in response to aloubyansky)Alex says:
I've added ClassInfos.disableCache(), enableCache(), isCacheEnabled(),
flushCache() and flushCache(String className) methods.
You can disable caching or flush it before running a test as part of setUp(), for example.
Does this work for you? -
8. Re: optimizing introspection/reflection
heiko.braun Jul 4, 2006 3:31 AM (in response to aloubyansky)This does still work on the static ConcurrentHashMap, right?
This will probably work for testing, but how do you want to prevent unexpected results in production? Basically everyone can enable/disable caching of XB all the time.
Plus there's a synchronization overhead and probably a memory leak when the map grows over time.
Why don't we associate ClassInfos with Marshaller/Unmarshaller instances?
ThreadLocal would be another option.
I think the suggested API works, but I am concerned about unwanted side effects due to this static member. -
9. Re: optimizing introspection/reflection
aloubyansky Jul 4, 2006 5:33 AM (in response to aloubyansky)heiko wrote:
Why don't we associate ClassInfos with Marshaller/Unmarshaller instances?
Makes sense to look into. But right now, we would have to use ThreadLocal's. Otherwise, changes in the public API would have to be done. Let's investigate this after the bugs are fixed.
In the mean time, static ConcurrentHashMap was replaced with synchronized WeakHashMap.