Interception causes a huge performance üpenalty
stephen Jun 5, 2008 8:35 PMWhile trying to increase the performance of my application I noticed that the ManagedEntityIdentityInterceptor takes a lot of time doing its magic.
What's worse: If I understand it correctly it only deals with passivation and replication, but even if those never happen you pay the price at each and every request.
To have some hard facts I timed the initial display of the first page in my conversation (using the TimingInterceptor described in a previous performance related thread):
With ManagedEntityIdentityInterceptor: Each usage of my bean from EL expressions in my facelets page costs about 80ms!
757,70 ms 10 DocumentHome.getShowProductRelatedControls() 408,66 ms 5 DocumentHome.getCategory() 201,10 ms 1 DocumentHome.setProductGroupId() 167,36 ms 2 DocumentHome.getShowCompanyRelatedControls() 161,20 ms 1 DocumentHome.init() 161,11 ms 2 DocumentHome.getShowTemplateRelatedControls() 146,60 ms 1 EntityHome.create() 137,19 ms 1 DocumentHome.getDropdownProductGroupList() 108,59 ms 1 DocumentHome.getCanSeeAdminDoctypes() 93,83 ms 1 DocumentHome.getProductId() 92,16 ms 1 DocumentHome.getDocumentTypes() 88,73 ms 1 Home.getId() 87,61 ms 1 DocumentHome.getProductGroupId() 84,77 ms 1 DocumentHome.getDocKindCode() 75,84 ms 1 DocumentHome.getIsInternal() 71,77 ms 1 DocumentHome.getShowProductSpecificControls() 69,24 ms 1 DocumentHome.getCompanyId() =========== 2913,46 ms
Without ManagedEntityIdentityInterceptor my applications works just as fine but the requests takes less than 1/10 the time:
98,14 ms 1 DocumentHome.setProductGroupId() 72,52 ms 1 EntityHome.create() 57,99 ms 1 DocumentHome.init() 16,93 ms 1 DocumentHome.getDocumentTypes() 6,92 ms 10 DocumentHome.getShowProductRelatedControls() 2,32 ms 2 DocumentHome.getShowCompanyRelatedControls() 2,06 ms 5 DocumentHome.getCategory() 1,96 ms 1 DocumentHome.getDocKindCode() 0,88 ms 2 DocumentHome.getShowTemplateRelatedControls() 0,62 ms 1 DocumentHome.getDropdownProductGroupList() 0,57 ms 1 Home.getId() 0,48 ms 1 DocumentHome.getCanSeeAdminDoctypes() 0,43 ms 1 DocumentHome.getIsInternal() 0,43 ms 1 DocumentHome.getCompanyId() 0,34 ms 1 DocumentHome.getShowProductSpecificControls() 0,34 ms 1 DocumentHome.getProductId() 0,32 ms 1 DocumentHome.getProductGroupId() =========== 263,25 ms (The remaining time is almost exclusively spent with db queries that can pretty easily be optimized.)
There must be a better way to implement the features that the interceptor provides, don't you think?
A dozen calls to a simple getter can't really take a full second.
Any ideas?