Tuesday, March 31, 2009

JVM (GC) tuning useful links and Netbeans Heapwalker demo project

I want to add some useful document links which bring me up on this big topic--JVM (GC) tuning:
http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
http://java.sun.com/performance/reference/whitepapers/tuning.html
http://java.sun.com/j2se/1.5.0/docs/guide/vm/gc-ergonomics.html
http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf
http://java.sun.com/j2se/1.5.0/docs/guide/vm/server-class.html

For Heap dump analyzer, apart from Eclipse Memory Analyzer, there is another Cool free analyzer tool,Netbeans HeapWalker:
http://profiler.netbeans.org/docs/help/6.0/heapwalker.html

here is one very interesting HeapWalker Demo, for QA people who is interesting in trying to tune the performance memory issues, you may go through this message and get some sense of performance tuning by yourself :)

http://wiki.netbeans.org/HeapWalkerDemo

Tuesday, March 24, 2009

Dining Philosophers Game--how to make Deadlock issue

Try this game if you do not want to write a code to implement the deadlock issue:
snapshot:


play at below :
http://wwwhomes.doc.ic.ac.uk/~jnm/book/book_applets/Diners.html

利用Firebug实现Google Maps中国的地理译码

2007年8月在北京参加首届研究生地理信息系统论坛,在论坛上有幸介绍了一下陈汝烨和我在创建roommap网站时期的一个地理译码的过程,现在Google Maps中文的地理译码已经公开了一些地理译码信息,之前需要自己去“hack”这部分信息:
http://www.codechina.org/doc/google/gmapapi/#Geocoding_Etc

所谓地理译码:是把地址(如"1600 Amphitheatre Parkway, Mountain View, CA")转换为地理坐标(如经度-122.083739,纬度37.423021)的流程,您可以用它把数据库里面的街道地址或用户提供的地址信息标记在地图上。

现在将我们俩当时(2007年)的思路共享给大家:

摘 要:目前Google Maps 中国的API已经提供了地图所需要的基本服务,比如任何网站可以引用浏览Google maps中国地图,以及一些简单应用比如显示气象图等,但使用者不能进行地理译码。地理译码是把地址(如“中国科学院遥感应用研究所”)转换为地理坐标(如经度-122.083739,纬度37.423021)的过程。通过它,您就可以把数据库中的街道地址或用户提供的地址信息标记在地图上。但是,到目前为止,在Google maps US 已经实现了地理译码的API(GClientGeocoder 类中有相应的方法实现)。Google Maps中国地图中,用户可以对地名搜索并进行地理坐标定位,然而,中文 Google Maps API尚不提供地理译码功能。不过,我们可以根据Google提供的规范开发自己的地理译码器。本文介绍了利用Google maps网络已有资源,如何实现对中文地理位置名称到地理经纬度坐标的转换,从而在自己的网站中利用Google maps中国对任何国内的地理位置进行搜索定位。

作者采用Firebug监测工具,分析Google中国地图程序产生的Http响应,从中解析经纬度坐标信息,最终实现Google Maps中国的地理译码功能。

首先登录http://ditu.google.cn/网站,将需要查询的地名提交并提交。查看Firebug中获得命名为maps的Http响应(response),从相应的html文本中发现名为markers: [] 数组, [] 内每个id: 的内容就表示一个对象或称一个地理信息结果。由此按照markers: [] 数组内对象(或id)的数量,我们可以把地理译码过程分成一下三种情况:

1. markers: [] 数组中有多个对象(或id)。比如搜索“扬州大学“,那么地图上可以得到多个结果,包含扬州大学的多个校区的地址。在这种情况下markers: [] 数组中每个对象(或id)存在一个geocode的属性,在这个属性中我们发现了一个没有经过加密的该地址的地理坐标。因此,我们可以直接用正则表达式获取到改对象(或id)的经纬度信息,从而遍历得到每个地址的地理位置。

2. markers: [] 数组中仅有一个对象(或id)。比如搜索“中国科学院遥感应用研究所”,只有一个精确地址。这种情况下的http响应结果中包含一个markers数组,数组长度为1,这个数组包含的元素对象有laddr和mapabcPoiid两个属性。laddr就是中文地址描述,而作者发现Firebug监测到浏览器发送了标识为mapabcPoi的请求,从地址中中可以看到 Google地图的地理数据用的mapabc.com的数据,那么推断mapabcPoiid是该地理点在mapabc数据库中的标识符。作者查看mapabcPoi请求的响应内容(response),得到类似这样的代码notpcoStrbase64=…发现这个结果应该是base64编码后的结果,所以作者利用base64解码后就可以获得该地址的地理坐标了。

3. 找到多个不确定的结果。这种情况下,返回结果中包含一系列的建议的地址,比如搜索“上海马戏城” ,结果提示您找的是不是“某某路上的马戏城”。从响应的html文本中利用正则表达式取得这些建议的地址,然后再重新搜索就可以得到建议地址的坐标了

《注:代码部分已经由陈汝烨同学利用javascript实现》

结语:有时候,结果并不重要,过程更重要 :)

LR Vugen become slow when scripts is running with parameter notepad file opened

Today, I notice that LR(9.0) Vugen become slow when scripts is running with parameter notepad opened.

Vugen seems like a "snail" to execute your scripts line by line, once you close the parameter notepad file, then it become normal.

I am sure it is a bug in LR 9.0 , at least it is not fit my expectation :)

Monday, March 23, 2009

content check for web service calls (2)

I have written one way to do the XML content check for web service call:
http://joychester.blogspot.com/2009/02/content-check-for-webservicecalls.html

Here is another simple way to do this in Loadrunner if you find hard to write a Query(Xpath) in lr_xml_find:

Char Position;
......

lr_start_transaction("web service transaction");

web_service_call( "StepName=echo_101",

"SOAPMethod=MyService.MyServiceSOAP12port0.echo",

"ResponseParam=response",

"Service=MyService",

"Snapshot=t1156241380.inf",

BEGIN_ARGUMENTS,

"xml:part1=*******",

END_ARGUMENTS,

BEGIN_RESULT,

"part1/EchoOutput=Param_EchoOutput2",

END_RESULT,

LAST);

//want to match if the response data include Success Key word
Position= (char *)strstr(lr_eval_string("{response}"), "Success");

if (Position!=NULL) {

lr_end_transaction("web service transaction", LR_PASS);

}

else {
lr_output_message("web service call error occured!Help!:)"
}

Sunday, March 22, 2009

Nike Hyperdunk Supreme Kobe

科比不是我的偶像,他的球技出众,领袖气质,虽不讨厌,但打球的风格不是我欣赏的那种(俺的偶像是皮蓬,纳什):)

今天无意中在Nike factory看到了这双黑的出众的Nike Hyperdunk Supreme Kobe's PE, 是在去年10月份上市的,比起奥运版的白灰色,我觉得这款更具科比的个性--720CNY拿下(原价1250CNY):
“黑夜给了我黑色的眼睛,我却用它来寻找光明”:



还有一点,如果有你非常喜欢的鞋子,而且觉得贵,请忍耐半年的时间,然后去折扣店淘,祝你好运!

Wednesday, March 18, 2009

Garbage Collector Ergonomics digest

the “ParallelGC” will report one issue: "Out-of-Memory Exceptions", I found one material related to this issue and they give some suggestions to avoid "OOM" issue:

Quote:

The parallel garbage collector (UseParallelGC) throws an
out-of-memory exception if an excessive amount of time is being
spent collecting a small amount of the heap.

To avoid this exception, you can increase the size of the heap.
You can also set the parameters -XX:GCTimeLimit=time-limit and
-XX:GCHeapFreeLimit=space-limit where:

time-limit:
The upper limit on the amount of time spent in garbage
collection in percent of total time (default is 98).

space-limit:
The lower limit on the amount of space freed during a garbage
collection in percent of the maximum heap (default is 2).


Here is the article called Garbage Collector Ergonomics
http://java.sun.com/j2se/1.5.0/docs/guide/vm/gc-ergonomics.html

I also take the Java tuning White paper as a reference, which emphasis on the most important points of Java tuning:
http://java.sun.com/performance/reference/whitepapers/tuning.html

For heapsize part, it describe as following:
The maximum heap size of a Java application is limited by three factors: the process data model (32-bit or 64-bit) and the associated operating system limitations, the amount of virtual memory available on the system, and the amount of physical memory available on the system. The size of the Java heap for a particular application can never exceed or even reach the maximum virtual address space of the process data model. For a 32-bit process model, the maximum virtual address size of the process is typically 4 GB, though some operating systems limit this to 2 GB or 3 GB. The maximum heap size is typically -Xmx3800m (1600m) for 2 GB limits), though the actual limitation is application dependent. For 64-bit process models, the maximum is essentially unlimited. For a single Java application on a dedicated system, the size of the Java heap should never be set to the amount of physical RAM on the system, as additional RAM is needed for the operating system, other system processes, and even for other JVM operations. Committing too much of a system's physical memory is likely to result in paging of virtual memory to disk, quite likely during garbage collection operations, leading to significant performance issues. On systems with multiple Java processes, or multiple processes in general, the sum of the Java heaps for those processes should also not exceed the the size of the physical RAM in the system.

The next most important Java memory tunable is the size of if the young generation (also known as the NewSize). Generally speaking the largest recommended value for the young generation is 3/8 of the maximum heap size. Note that with the throughput and low pause time collectors it may be possible to exceed this ratio. For more information please see the discussions of the Young Generation Guarantee in the Tuning Garbage Collection with the 5.0 Java Virtual Machine document.


For GC algorithms you can choose from:
* The -XX:+UseParallelGC parallel (throughput) garbage collector, or
* The -XX:+UseConcMarkSweepGC concurrent (low pause time) garbage collector (also known as CMS)
* The -XX:+UseSerialGC serial garbage collector (for smaller applications and systems)


first two choices are most common for large server applications. The white paper give us a lot of tuning examples, I have to say "tuning is an art more than science, there is no silver bullet". Please keep your tuning work for always...

If you have any other questions:

1> remember FAQ, although it is based on JDK1.4.2, very helpful!
http://java.sun.com/docs/hotspot/gc1.4.2/faq.html

2> read "Tuning Garbage Collection with the 5.0 Java[tm] Virtual Machine" again:

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

Friday, March 13, 2009

<微软如何测试软件>国内可以买到了:)

今天发现这本书已经在卓越网上有的卖了,有意思,而且也不算太贵,比起亚马逊网站的报价:$29.69, 卓越的报价是¥136=$20 :)



Interview with Alan Page on This Book:
http://www.youtube.com/watch?v=ushDnjJTLi0&hl=en&fs=1
http://www.youtube.com/watch?v=PussKcpJrik&hl=en&fs=1

More detail book info at Joyo:
http://www.amazon.cn/mn/detailApp?ref=BR&uid=168-2551957-2466640&prodid=enbk626384#

JavaScript Memory Leak Detector band on IE7

以前测试browser端(IE/FireFox/Safari)的memory leak问题,经常采用的方法就是手工走遍整个页面的flow,在经过每个页面的时候,反复刷新该页(5次以上)。。。观察task manager上的memory trend是否增长,从而初步判断出哪张页面可能存在内存泄漏的问题。不过真正找到leaks的原因还是需要费一番周折,而且需要经验的积累才能较快的定位问题。

也曾经用过Drip这个小工具,可以自动刷新页面,找到有内存泄漏的页面,并且可以看出DOM 中有问题的对象:
How to fix the leaks:
http://www.outofhanwell.com/ieleak/index.php?title=Fixing_Leaks

最近发现GPDE小组(Global Product Development - Europe team)去年已经发布了Beta版本的JavaScript Memory Leak Detector,作为IE7的一个插件帮助开发来找到Leaks:

http://blogs.msdn.com/gpde/pages/javascript-memory-leak-detector.aspx

Here is the brief intro of this tool:
JavaScript Memory Leak Detector (download) is a debugging tool to detect memory leaks in JavaScript code. It can be installed as an Internet Explorer band and it is expressly designed to find memory leaks in JavaScript code that runs in Internet Explorer. Cool, hmm...

一般情况下,如果用户习惯不是反复操作同一张页面,那么少许的内存泄漏(根据典型用户的机器配置来综合考虑)也可以暂时忽略。

Wednesday, March 04, 2009

生活中的“隔离测试”

Ad-Hoc testing:
今天回到家,发现房间的台灯A坏了,昨天用的还好好的呢。。。。

Log one defect here for tracking

Try to reproduce this issue and find more clues/isolation test in order to do further discussion and decision making

Pre-conditions
1.假设在本实验阶段,没有出现停电,短路,断路等异常情况,一切环境在万分和谐的情况下顺利进行:)
2.台灯A和台灯B上的台灯需要可以相互兼容,灯泡的最高功率应均小于两个台灯支持的功率上限

Isolation steps:
1》拿了另外房间里一个完好的台灯B来尝试,发现插座是好的,也通着电;

2》把坏的台灯A上的灯泡拿下来,放在好的灯座B上,打开台灯B,发现台灯B不亮----灯泡A本身有问题,但也不能排除灯座A本身也存在问题

3》进一步排除灯座A的问题,将灯泡B安装在灯座A上,打开台灯A,发现灯泡B依然闪亮---灯座A本身没有问题,可以断定因灯泡A(老化或质量)问题引起。

Action plan
等周末去超市买个新灯泡换上,问题解决!

Close this bug, make it as Closed,add your comments

Sunday, March 01, 2009

急性胃肠炎初判

症状一:肚子难受,隔气,但还不时的想吃东西
症状二:突然的上吐下泻(基本吃啥吐啥)
症状三:头晕发热
症状四:胃部(肚子的左下部位)有持续的微痛。

那么这些症状都符合的话,这说明你可能得了急性胃肠炎。。。。

如果没有身体脱水的话,可以吃药来治疗:

1. 消炎药:头孢克洛分散片
2. 止泻药:香连片
3. 止痛养胃药:蒙脱石散

饮食尽量不要吃肉类以及高蛋白的食物,要以清淡,新鲜,易于消化的蔬菜,米粥为主。平时多喝开水,最好加点盐,补充拉肚所丢失的水分以及盐分:)

大家切记,身体健康始终是第一位的!无论什么时候,都不要跟自己的身体开玩笑!