Eclipse Profiler Plugin

Eclipse Profiler Plugin

This is a plugin for the Eclipse platform which allows java code profiling. Project

License

CPL.

 

General note

1.) if you run the remote profiler, the filter settings      in the eclipse environment are not taken into account.      Instead you must provide the filter settings in the      start command of your application server. You do this      by adding an environment variable __PROFILER_PACKAGE_FILTER      to the startup command of your aplication, see below.  2.) Setting up the profiler package filters (in general)      You must define the environment variable __PROFILER_PACKAGE_FILTER      as shown below in the examples for tomcat, jboss, weblogic and      resin.       General important Note:      The environment variable contains following parts:            the application starting class (__A__)      inclusion filters              (__P__)      exclusion filters              (__M__)            You must provide exactly one starting class, but you      can have multiple inclusion and exclusion filters.       The parts MUST be separated by the OS specific      path.separator, i.e. ":" for unix or "$$" for      WINDOWS platforms)       example package filter setting for WINDOWS: -D__PROFILER_PACKAGE_FILTER=__A__org.apache.catalina.startup.Bootstrap;__M__sun.;__P__my.company.classes.         example package filter setting for UNIX/LINUX: -D__PROFILER_PACKAGE_FILTER=__A__org.apache.catalina.startup.Bootstrap:__M__sun.:__P__my.company.classes.         In the examples below we provide the WINDOWS style. Please      take care to use the LINUX/UNIX style if that aplies to you.             

Win32 installation

Copy ProfilerDLL.dll from root plugin folder into bin folder of your JRE installation. You can skip this step, plugin will ask you and copy DLL into your JRE\BIN when you will start profiling local application inside of Eclipse first time. It will also check, that you have in JRE\BIN same DLL as in plugin directory.

Linux installation

Profiler has native part compiled with gcc 3.2, but if you have old gcc or libraries you can build native part yourself. Extract files from native\profiler_linux.tgz and look at script "m". This is example of compilation script. Change it as needed for you OS.
See also profile_cpu/profile_heap for examples of start line for cpu and heap profiling and r_cpu/r_heap as example how to use them.

Usage

Profiler plugin creates additional kind of launch configuration in Run menu. Profiler tab allows the user to define packages which shouldn’t be instrumented, thus, all time usage will be referred to calling methods.
You can specify refresh rate, i.e. how often plugin will read statistics from prolifing JVM.
You can also set method, how to get time of enter in method and leave. There are two methods: fast, but usefull only if you have one active thread, which tries to use all CPU; or slow, which use JVMPI function GetCurrentThreadCpuTime() and allows detect how much of CPU was used by thread. However with this method profiled program runs about 3 times slower than with fast method.


Fig. 1. Launch configuration.

 

Profiler supports inclusive (grren) and exlusive (red) filters. You can noy only specify what packages should be excluded from instrumentation, but also what packages should be included. Usefull, if you want to profile only your own classes. You can move filters up and down using buttons or drag and drop.


Fig. 1.1. Drag filters.

 

Plugin allows remote profiling with "Remote Profiler" launch configuration. Notice, that remote profiling is supported only in "run" mode, i.e. when you create launch configuration using "Run|Run…" menu item.
You need to start remote application with special switches like: java -XrunProfilerDLL -Xbootclasspath/a:jakarta-regexp.jar;profiler_trace.jar;commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__M__sun.;__M__com.sun. -D__PROFILER_USE_PACKAGE_FILTER=1 Here __M__ prefix used for exclusive filter, __P__ can be used for inclusive filter. And you should use __A__ for class with method "main".


Fig. 2. Remote launch configuration.

 

Tomcat CPU profiling

Profiler was tested with jakarta-tomcat-4.1.12. Add after lines in catalina.bat:
set _EXECJAVA=%_RUNJAVA%
set MAINCLASS=org.apache.catalina.startup.Bootstrap
set ACTION=start
set SECURITY_POLICY_FILE=
set DEBUG_OPTS=
set JPDA=
following line:
set JAVA_OPTS=-XrunProfilerDLL:1 -Xbootclasspath/a:jakarta-regexp.jar;profiler_trace.jar;commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__A__%MAINCLASS%;__M__sun.;__M__com.sun.;__M__java.;__M__javax.;__M__org.apache. -D__PROFILER_TIMING_METHOD=1
Then copy jar’s: commons-lang.jar jakarta-regexp.jar profiler_trace.jar to bin directory of tomcat. Now you can start tomcat using startup.bat and it will gather statistics for you. Next step is configuring Eclipse. You should create remote launch configuration and set host address as needed. This is all. Launch it, plugin will connect to your Tomcat and show you some statistics.

Tomcat heap profiling

Profiling heap is almost same as CPU profiling, but you should use following line:
set JAVA_OPTS=-XrunProfilerDLL:3,10,0 -D__PROFILER_PROFILE_HEAP=1 -Xbootclasspath/a:jakarta-regexp.jar;profiler_trace.jar;commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__A__%MAINCLASS%;__M__ -D__PROFILER_TIMING_METHOD=1

JBoss profiling

Profiler was tested with jboss-3.0.6_tomcat-4.1.18. Add following line in your bin/run.bat (directly after echo off):
set JAVA_OPTS=-XrunProfilerDLL:1 -Xbootclasspath/a:jakarta-regexp.jar;profiler_trace.jar;commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__A__org.jboss.Main;__M__sun.;__M__com.sun.;__M__java.;__M__javax. -D__PROFILER_TIMING_METHOD=1
Then copy jar’s: commons-lang.jar jakarta-regexp.jar profiler_trace.jar to bin directory of JBoss. Now you can start JBoss using run.bat and it will gather statistics for you. Next step is configuring Eclipse. You should create remote launch configuration and set host address as needed. This is all. Launch it, plugin will connect to your JBoss and show you some statistics.

WebLogic profiling

Profiler was tested with WebLogic 8.1, installed in "c:/bea". WebLogic has its own JRE’s, so you will need to copy ProfilerDLL.dll manually to C:\bea\jdk141_02\jre\bin. For profiling examples, change file C:\bea\weblogic81\samples\domains\examples\startExamplesServer.cmd, line where JAVA_OPTIONS is defined:
set JAVA_OPTIONS=-XrunProfilerDLL:1 -Xbootclasspath/a:jakarta-regexp.jar;profiler_trace.jar;commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__A__weblogic.Server;__M__sun.;__M__com.sun.;__M__java.;__M__javax.;__M__weblogic. -D__PROFILER_TIMING_METHOD=1
Then copy jar’s: commons-lang.jar jakarta-regexp.jar profiler_trace.jar to "C:\bea\weblogic81\samples\domains\examples". Now you can start WebLogic examplex using startExamplesServer.cmd, or shortcut in Windows menu, and it will gather statistics for you. Next step is configuring Eclipse. You should create remote launch configuration and set host address as needed. This is all. Launch it, plugin will connect to your WebLogic and show you some statistics.

Resin profiling

Profiler was tested with Resin-ee 2.1.10. Create batch file with following content in "bin":
httpd.exe -J-XrunProfilerDLL:1 -Xbootclasspath/a:c:/prof/jakarta-regexp.jar;c:/prof/profiler_trace.jar;c:/prof/commons-lang.jar -D__PROFILER_PACKAGE_FILTER=__A__com.caucho.server.http.HttpServer;__M__sun.;__M__com.sun.;__M__java.;__M__javax. -D__PROFILER_TIMING_METHOD=1
Then create directory "prof" in disc "C" and copy jar’s: commons-lang.jar jakarta-regexp.jar profiler_trace.jar. Now you can start your batch file and it will gather statistics for you. Next step is configuring Eclipse. You should create remote launch configuration and set host address as needed. This is all. Launch it, plugin will connect to your Resin and show you some statistics.

Options

Profiler supports several options via -DXXX.

Options Description
__PROFILER_PACKAGE_FILTER Contains list of packages to include or exclude.
Here __P__ – inclusive pattern, __M__ – exclusive pattern.
And __A__ – application start class.
Examples:
Include only ru.* and de.* packages: __P__ru.;__P__de.
Exclude system packages: __A__org.jboss.Main;__M__sun.;__M__com.sun.;__M__java.;__M__javax.
If at least one inclusive pattern used, only classes accepted by inclusive patterns will be instrumented.
__PROFILER_TIMING_METHOD Specifies timing method – how to measure elapsed time.
0 – fast, System.currentTimeMillis(), good for application without sleeps and waits.
1 – precise, thread aware, slow, good for multithreaded applications.
2 – sampling profiling, very fast, good for long runned processes.
__PROFILER_PROFILE_HEAP 1, if HEAP profiling should be used.
__PROFILER_AUTO_START 0 – don’t start automatically.
1 (default) – start automatically.
__PROFILER_START_ON_METHOD Start method name. When applications tries to enter in this method profiling starts (see __PROFILER_AUTO_START, it should be 0).
Example: -D__PROFILER_START_ON_METHOD=ru.nlmk.train.Main.mainLoop
__PROFILER_PAUSE_ON_METHOD 1, if you need pause profiling when __PROFILER_START_ON_METHOD leaved.
__PROFILER_INSTRUMENT_SYSTEM_CLASSES 1, if you need instrument additional system classes, like java.lang.String, etc. Expensive!
__PROFILER_WAIT_FRONTEND_CONNECT 1, if you need to wait, until frontend (plugin) will connect. (0 by default).

CPU profiling

Profiler supports CPU profiling and basic function for heap profiling. The profiler collects invocation count and direct time statistics for every method. Direct time is the amount of time used by selected method for execute. Also a total time value displayed in calling tree for selected thread. The total time means a time used by selected method and by all the methods it had called.

Only instrumentation profiling method is supported because of its precise. The overhead expenses reflects at speed decreasing app. 5 times to normal.

How it works

The profiler subscribes for JVPMI event JVMPI_EVENT_CLASS_LOAD_HOOK which called during every class loading. The profiler modifies loading byte-code by adding profiler’s method call "enter" in the beginning of the every method of loading class and at the end of it – "leave". "Enter" profiler’s method notes the time of entering to profiling method. "Leave" makes method leaving timestamp and calculates a difference between enter and leave timestamps. This difference means total time for this method call. Direct time calculates as total time of this method minus total time of the all methods called by it. The profiles makes some time corrections for the time spent by profiler.

The profiler implemented as an Eclipse perspective with following views: Threads, Packages, Classes, Methods, Thread methods, Thread call tree, Heap.

Threads.
Shows a list with all threads (alive or dead) in the current process. Here you can pause/resume refreshing of statistics in views, pause/resume all threads in profilied program, clear all statistics or run GC in profiled JVM.


Fig. 3. Threads View.

 

Call graph.
Profiler uses Draw2D for displaying call graph of thread. All methods shown in several columns, column depends on level, on which this method was called. Inside one column methods sorted by direct time used. Each node in graph has color from red to dark gray, depending on direct time. Methods with maximum time use have red color, and methods, which almost don’t use time, have grey color. Each method has hint with detailed information. You can double click on method to open it in editor.
Lines between method present call from source method to target. Lines from one level to directly next have black color, to next – blue, inside one level – red, and from backward calls – green. Width of line depeneds on how much of time use in this call.


Fig. 3.1. Call graph.
You can also see hit for call.
Fig. 3.2. Call hint.
As you can see, full graph looks fairly complex, but you can select part of it. Press mouse on some method and select then button "Show callers", "Show calles" or "Show caller and callees". You can see something like this:
Fig. 3.3. Callers.

Fig. 3.4. Callees.

Fig. 3.5. Callers and callees.
You can double click on call line for opening editor with source method with highlighting places, where it calls target method.
Fig. 3.6. Show calls.

 

Packages.
Shows a list with all methods with class hierarchy from package. This allows to determine packages which used the most of CPU time. In this view (and in Classes and Methods views also) the user can see in gray color the methods with unmodified parameters since last update. The user can hide such kind of methods by applying appropriate filters.
Here:
Name – name of package/class/method
Inv. – invocation count
% – percent of all invocations
Time – direct time used
% – percent of total time
Time/Inv. – average time used for one invocation
Total time – total time used directly by method and by all methods it calls
Inst. time – time used for instrumentation of class


Fig. 4. Packages View.

 

You can add package or class to filter by pressing right mose button on element in table and selecting menu item. Filter can be added to launch configuration filter (will be used in next profiling, if you will active it) or to view filters (will be activated right now).


Fig. 4.1. Add filter.

 

Classes.
Shows a list of all class methods with method hierarchy from class. This allows to determine classes with the most CPU time usage.


Fig. 5. Classes View.

 

Filters.
Allows to define which kind of methods can be shown.


Fig. 6. Filters.
You can save configured name patterns (inclusive or exalusive) with some name and description, then you will able to select them in check list box.
Fig. 6.1. New filter.
Later you can change this user defined filter.
Fig. 6.2. Edit filter.

 

Methods.
Shows the statistics for all methods of the current process.


Fig. 7. All Methods View.

 

Thread methods.
Shows methods statictics for thread selected in Threads View.


Fig. 8. Thread Methods View.

 

Thread tree.
Shows a methods invocation tree for thread selected in Threads View. Here red square used for highlighted methods (from thread methods context menu) and green dot used for all other methods.


Fig. 9. Thread Tree View.

 

Inverted thread tree.
Shows a methods invocation tree for thread selected in Threads View starting from leaves. This allows you fastly detect, that some leaf method uses much of total time and see, what methods it is called.


Fig. 9.1. Inverted thread Tree View.

 

Heap.
Shows heap usage graph: total (green), used (blue) and free (yellow) heap.

Heap View.
Fig. 10. Heap View.

 

Here is an overall view of the profiler perspective. You can see a method HashMap.put opened in source code editor with highlighted lines of code which has the maximum hit count (size of annotation depends on hit count). You can open source code editor by choosing menu item "Open method in editor" in context menu.


Fig. 11. Perspective.

WYSIWYG 網頁線上編輯器比較表


在 OpenSource 的 WYSIWYG Editor 當中,早期最多人使用的 HTMLArea 由於原開發團隊進度緩慢,Bug 也很多,造成不少人想跳槽。


這裡有一份幾乎涵蓋所有 WYSIWYG 線上編輯器比較表:


http://www.geniisoft.com/showcase.nsf/WebEditors


OpenSource 跟商用的都有。不過這份資料還是有點小錯誤,像 FCKeditor 的網址也不正確,這些我會回報過去,相信應該很快就可以更正過來。


在 OpenSource 當中,目前風評較佳的是 TinyMCEFCKEditorXinha


其中 TinyMCE 最受大多數人青睞,速度快又穩定,目前也逐漸提供 Safari 的支援。然而 TinyMCE 除了 HTMLArea 原有的功能外,也導入了 Image Manager + Editor ,可以線上管理及簡單的修改圖片。

至於商用的就沒有研究了,有興趣的人可以去玩玩看囉。^^

NOD32最新升级ID

Username: AV-6656986
Password: bk6soccp0o

Username: AV-6383678
Password: hsyfc640um

Username: AV-6294494
Password: 53u6p5gndm

Username: AV-6171271
Password: w55beid6gj

Username: AV-6588188
Password: 2dtb6t8pgf

Username: AV-6697455
Password: wonn9hqfw6

UserName: AV-6504753
PassWord: swhmfw9i0g

Username: AV-6670664
Password: 17s9x8bgfk

UserName: AV-6383678
PassWord: hsyfc640um

Username: AV-6661155
Password: jeay9be0ix

優化resin

修改RESIN_HOME/bin/wraper.pl

 

 

$JAVA_ARGS=”-server -verbose:gc -Xdebug -Xloggc:gc.log -Djava.awt.headless=true -XX:PermSize=128M -XX:+UseConcMarkSweepGC -Xms512m –
Xmx512m”;

 

仲有

 

$DEFAULT_STACK_SIZE=”-Xss512k”;

as4安裝JDK5/JDK6

由於AS4自帶嘅JDK系1.4

而我開發的系統使用JDK5,所以要重新安裝JDK5.

 

先下載JDK.http://java.sun.com

 

解壓到 /usr/lib/jdk1.6.0_01/

 

建立連接 ln -s /usr/lib/jdk1.6.0_01 /jdk

修改 vi /etc/profile

 

 

export JAVA_HOME=”/jdk/”

export RESIN_HOME=”/resin/”

export JAVA_BIN=”/jdk/bin/”

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

 

完成!

Resin多域名绑定 one resin two hosts


Resin多域名绑定



需求:
group.XXX.com
XXX.group.XXX.com
都指向同一系统


 <host id=”group.aaa.com”>
 <host-alias-regexp>([a-zA-Z0-9.]+)roup\.([^.]+)\.com</host-alias-regexp>
 <host-name>${host-alias-regexp.regexp[1]}roup.${host-alias-regexp.regexp[2]}.com</host-name>
 <root-directory>.</root-directory>
 <web-app id=”/” document-directory=”e:\group_aaa”/>
 </host>
 
启动Resin后,访问
1234567
 http://a.group.aaa.com/
 http://group.aaa.com/
 http://group.bbb.com/
 http://a.group.bbb.com/
 


都能访问到同一系统。


本站使用的域名是
<host id=”strongd.net”>
  <host-alias-regexp>([a-zA-Z0-9.]+).strongd\.net</host-alias-regexp>
  <host-name>${host-alias-regexp.regexp[1]}.strongd.net</host-name>
  <root-directory>.</root-directory>


绑定指定的几个域名的方法也一样.例如只允许abc.cn/abc.com,gofor.cn,gofor.com,yes001.cn.yes001.com访问的话.可以这样写:


 <host id=”aaa.com”>
 <host-alias-regexp>([a-zA-Z0-9.]+).(abc|gofor|yes001+)\.(com|cn)</host-alias-regexp> 就在这个地方(abc|gofor|yes001+)\.(com|cn)
 <host-name>${host-alias-regexp.regexp[1]}.${host-alias-regexp.regexp[2]}.${host-alias-regexp.regexp[3]}</host-name> 使用了三个正则表达式,
 <root-directory>.</root-directory>
 <web-app id=”/” document-directory=”e:\group_aaa”/>
 </host>

Error * Expected format ‘3’ of repository; found format ‘5’

What gives this error?

I’m using svnserve.exe on windows (svn-win32-1.3.2). When trying to connect with TortoiseSVN (1.4.3, Build 8645) I get the error.

The repository has been copied from another machine, where it ran fine, possibly using an older version of the svn server.

TIA!

 

 

 

Hi there,

exactly what you’ve written. you copied the repository from a machine where Subversion 1.4 has been running. you shouldn’t simply copy the repos.

Just do an svnadmin dump of the source machine and make an svnadmin load on your destination machine.



Subversion’s repository database schema has changed occasionally during development. Old repositories, created with a pre-1.0 development version of Subversion, may require the following operation when upgrading. If a schema change happens between Subversion releases X and Y, then repository administrators upgrading to Y must do the following:



  1. Shut down svnserve, Apache, and anything else that might be accessing the repository.
  2. svnadmin dump /path/to/repository > dumpfile.txt , using version X of svnadmin.
  3. mv /path/to/repository /path/to/saved-old-repository
  4. Now upgrade to Subversion Y (i.e., build and install Y, replacing X).
  5. svnadmin create /path/to/repository, using version Y of svnadmin.
  6. svnadmin load /path/to/repository < dumpfile.txt , again using version Y of svnadmin.
  7. Copy over hook scripts, etc, from the old repository to the new one.
  8. Restart svnserve, Apache, etc.

忘記mysql 密碼的取回方法

如果 MySQL 正在運行,
首先殺之: killall -TERM mysqld(如果是windows,直接調出進程管理器,結束之)
以安全模式啓動 MySQL :
/usr/bin/safe_mysqld –skip-grant-tables &
(windows 下 mysql安裝所以盤/mysql/bin/safe_mysqld –skip-grant-tables )
就可以不需要密碼就進入 MySQL 了。
然後就是
>use mysql
>update user set password=password("new_pass") where user="root&quot$$
>flush privileges;
重新殺 MySQL ,用正常方法啓動 MySQL 。

在AS4下安裝/升級MySql5問題.

 安裝MySQL 5出錯
1. 既便安裝RHEL時没有選擇安裝MySQL,在安裝MySQL5時也會出錯,説與MySQL4衝突

2. 實際上RHEL安裝了一些MySQL相關的DBD、OBDC、PHP-MySQL等

3.1.2 卸載MySQL4

1. 使用“rpm -qa | grep mysql”查看MySQL4及其相關的安裝軟件

2. 逐個使用rpm –e ––nodeps 强制卸載MySQL4

3.1.3 安裝MySQL5

使用rpm –ivh正常安裝即可。

3.1.4 MySQL5無法啓動

是因為SELinux(安全Linux)使能了,導致MySQL5没有訪問權限。

關閉SELinux或配置相應的目録權限即可。

3.1.5 遠程訪問MySQL

不管用何種方式(用自己寫的程序和MySQL Query Browser),都無法連接mysql數據庫,提示如下:

Could not connect to the specified instance.

Mysql error number 1130

#HY000Host ‘hostname’ is not allowed to connect to this MySQL server

權限問題,打開mysql數據庫中的user表,把你用來連接數據庫的用户所在那條記録的host字段改成%就行了。

%表示可重任何地方連接到mysql服務器,LOCALHOST表示只能在mysql所在服務器進行連接。在用户授權時是可能限定ip地址或地址段進行連接的。

你可以查閲mysql用户授權相關資料,另外當用户授權項發生變化時請更新授權表,否則不會生效。

3.2 如何重啓MySQL

#service mysql restart

3.3 停止與啓動MySQL

要啓動 MySQL 的方法:(以本文將 MySQL 安裝在 /usr/local/mysql 為例)
# /usr/local/mysql/share/mysql.server start