I am profiling my application which uses Spring, Hibernate, and mysql-java-connector. The VisualVM shows that more than 50% of CPU time is spent in com.myql.jdbc.utils.ReadAheadInputStream.fill()
method when there are 1000 parallel connections doing read.
Is there any optimization to make it faster?
VisualVM counts a thread as using CPU time whenever the JVM thinks it's runnable. This means that any thread not waiting on a lock is considered runnable, more or less, including threads waiting for I/O in the kernel! This is where the large amount of CPU usage in com.myql.jdbc.utils.ReadAheadInputStream.fill()
is coming from. So instead of a CPU problem you have an I/O problem.
There are some things you can do on the JVM side, but not a lot of straightforward optimizing:
On top of the other suggestions, consider also experimenting with a much lower amount of connections (i.e. 20). It's very possible that the overhead of handling such a large amount of open connections is slightly fooling your profiling observations.
Not least, make sure you're using a recent version of Hibernate ORM. We made version 5.0+ much smarter than previous versions, especially regarding performance improvements ;-) Improvements are applied daily, so keeping up to date or at least trying the latest might be an easy win.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With