-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Adrian Moos opened SPR-12755 and commented
We are using ProxyFactory to decorate Spring Beans when passing them over an api boundary to give each caller a proxy object of their own.
We have now noticed that proxy creation is quite an expensive process, taking 0.3 ms per proxy object, even though the proxies were all for the same target class in this test.
Analysis with JProfiler yielded the attached screenshot. Apparently, the proxy class is reused, but the objenesis ObjectInstantiator is recreated for every call to getProxy().
The objenesis tutorial recommends:
To improve performance, it is best to reuse the ObjectInstantiator objects as much as possible. For example, if you are instantiating multiple instances of a specific class, do it from the same ObjectInstantiator. Both InstantiatorStrategy and ObjectInstantiator can be shared between multiple threads and used concurrently. They are thread safe.
Affects: 4.1.2
Attachments:
- JProfiler Session.png (84.87 kB)
Issue Links:
- Add ability to create proxy around classes that has no default constructor [SPR-10594] #15223 Add ability to create proxy around classes that has no default constructor
- ObjenesisCglibAopProxy's fallback mode triggers duplicate class definition error [SPR-13131] #17722 ObjenesisCglibAopProxy's fallback mode triggers duplicate class definition error
Referenced from: commits 287045e