MyEclipse Performance Tuning First Experience

Source: Internet
Author: User

MyEclipse Performance Tuning First experience
a brief introduction to the working environment, MyEclipse2014, you know.
There is a Web-based workflow engine in the project, as long as the CPU is almost exhausted (although it looks like 27%, it has completely accounted for one of the cores of my 4-core CPU)

A quick way to start profiling:
Right-click on the project root directory
Create a new configuration under the MyEclipse Server application project
The Prject and server options are visible in the tab page of main, and I have only one TOMCAT7 supported Web project here.

Click the Profile button in the lower right corner.
You launch your own Web project in Tomcat and automatically start the Performance tool for monitoring. The author here automatically launches is VISUALVM 1.3.6, your own version of the installation may be different
Once the tool is started, you can see the section on whether it is CPU monitoring or memory monitoring. I am here because the project is CPU-occupied, so select CPU
The following hotspot methods can be seen on the monitoring interface
Except for the methods of the system's API classes (which are usually consumed by the business method invocation multiple times), the Executorengine.execute () method was found to be the culprit. Well, head straight to this method and discover that there is only one polling snippet while (true) {
//Gets an event in the queue EventInfo EventInfo = Eventmangecenter.takeevent ();
if (eventInfo! = null) {
//Insert an event into the database first
inserthistoryevent (eventInfo);
//Perform handlers for listeners registered by event type
Executeprocessbyeventtype (eventInfo);
//Execute handlers for listeners registered by event encoding
Executeprocessbyeventcode (eventInfo);
//Perform handlers for listeners registered by event type and event encoding
executeprocess (eventInfo);
}} and Eventmangecenter.takeevent (); The method is as follows */public EventInfo takeevent () {
EventInfo info = null; if (queueeventinfo.peek () = null) {
//Remove the first bar and delete
info = queueeventinfo.poll ();
} return info;
Takeevent does not complete the function it should have: Block public EventInfo takeevent () {
EventInfo info = null; if (queueeventinfo.peek () = null) {
//Remove the first bar and delete
info = queueeventinfo.poll ();
} return info;
}
At this point, the cause of the problem is found, and then it is defined as private queue<eventinfo> queueeventinfo modified to private blockingqueue<eventinfo> Queueeventinfo; Using Java's own blockingqueue to achieve rotation, there is data to start moving, no data waiting
Public EventInfo takeevent () throws Interruptedexception {return queueeventinfo.take ();
Start the Tomcat server project again, the CPU in the absence of service request, maintain 0% theoretical value, this is a service should have temperament well, haha


Come here, let's go into the next thing .

MyEclipse Performance Tuning First Experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.