Implementation of JarVisitorFactory.getBytesFromInputStream is not efficient. Data loaded from the stream is copied over and over again in memory as the data is fetched.
Because of this problem creation of local EntityManagerFactory is slow for us in hibernate 3.4.0 (~40 seconds). We profiled start-up and found this method being bottleneck (>90% of time spent). Although we have not tested creation of EntityManagerFactory with the latest version of hibernate, this method is there in hibernate 4.1.8 and should be updated.
Attached is alternative implementation of method and performance test.
In our test we loaded 2491475 bytes:
Current implementation: 219 ms
Suggested implementation: 5 ms
|