Sunday, August 12, 2007
is the rumer ture? Google will use flash to cross platform
I just saw gtalk in flash..
Wednesday, July 25, 2007
what I did last year?
Java code : 8000 lines
for the last week...I wrote 4000 lines C++!! and more work are coming.
Wednesday, July 18, 2007
don't abuse OS's cache
At first, I read it once a block (n bytes). I think it is fastest, because when I read the first block, OS should cache the whole page ( i.e. 4K) for future use. So when I fetch the next block, it doesn't need to load from hard-disk.
But when I change the reading method, each time reads 4K in to buffer, then separate from buffer, the speed boost up like 10 times.
Why? I think the reason lies in when you ask OS to load data, it will invoke system call, then Interrupt, and the OS copy the data from kernel mode to user mode for your use. This also cost time.
Tuesday, July 17, 2007
direction of computing
Hmm, I have loved both three technology, was hoping openMosix can turn hundreds of old machine into a super power computer.
But now, hardware development out weight the software. multi-cpu, multi-core has gained more attention. I hope this can give us unlimited computing power.
here is the announce:
link: http://sourceforge.net/forum/forum.php?forum_id=715406
Posted By: bruceknox
Date: 2007-07-15 09:35
Summary: openMosix Project End of Life Announcement
Tel Aviv (July 15, 2007) - openMosix Project Ending
Moshe Bar, openMosix founder and project leader, has announced plans to end the openMosix Project effective March 1, 2008.
The increasing power and availability of low cost multi-core processors is rapidly making single-system image (SSI) Clustering less of a factor in computing. The direction of computing is clear and key developers are moving into newer virtualization approaches and other projects.
openMosix has been a very successful project with tens of thousands of installations. Another measure of this success is found in the many projects that have incorporated openMosix into their own products.
openMosix’ Auto-Discovery innovation paved the way for the Instant SSI Clusters that soon exploded the number of cluster installations. Instant Clusters made installation and setup automatic for the non-computer specialist and for the first time brought significant computing power to many researchers worldwide.
openMosix also broke new ground in Operating Systems theory including important lessons learned in Distributed Shared Memory and other challenging areas. Many individuals have learned Linux kernel development through openMosix which has been used in computing curriculum, laboratories, and research.
openMosix source will remain on SourceForge indefinitely, frozen as of March 1st, 2008. The openMosix website will remain open until March 1st, 2008 and the openMosix-Devel List will close as of December 1, 2007.
Moshe Bar stated that, “I wish to thank all the users and developers who enthusiastically supported openMosix and made the project such a success.”
Project website is http://www.openmosix.org/
openMosix is a Linux kernel extension for single-system image (SSI) clustering that allows building a cluster from ordinary networked computers. Applications benefit without modification specifically for openMosix.
auto generate code using UML
ps: I use open source tool dia to draw UML, and it can generate code. or use dia2code.
Sunday, July 15, 2007
automatic test for http interface
That make QA life easier.
here is my page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>login test</title>
</head>
<body>
<script type="text/javascript" language="javascript">
var http_request = false;
var output = null;
var expect = null;
var pass_out = null;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
// code for IE
if (window.ActiveXObject)
{
var doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(result);
}
// code for Mozilla, Firefox, Opera, etc.
else
{
var parser=new DOMParser();
var doc=parser.parseFromString(result,"text/xml");
}
var xml=doc.documentElement;
document.getElementById(output).innerHTML = xml.childNodes[1].childNodes[0].nodeValue;
if ( parseInt(document.getElementById(output).innerHTML) == parseInt(expect))
{
document.getElementById(pass_out).innerHTML = "<font color=\"green\">" + "PASS" + " </font>";
}
else
{
document.getElementById(pass_out).innerHTML = "<font color=\"red\">" + "FAIL" + " </font>";
}
} else {
alert('There was a problem with the request.');
}
mutex = 1;
}
}
var mutex = 1;
function get(user, pass, my_output, my_expect_output, my_pass_out) {
if(mutex == 1)
{
mutex = 0;
var poststr = "user=" + encodeURI( document.getElementById(user).value ) +
"&pass=" + encodeURI( document.getElementById(pass).value );
output = my_output;
pass_out = my_pass_out;
expect = document.getElementById(my_expect_output).innerHTML;
makePOSTRequest('/cgi-bin/login.fcgi', poststr);
}
else
{
setTimeout('get(\"'+user+'\",\"'+pass+'\",\"'+my_output+'\",\"'+my_expect_output+'\",\"'+my_pass_out+'\")', 1000);
}
}
function test_all()
{
document.getElementById("button1").click();
document.getElementById("button2").click();
document.getElementById("button3").click();
document.getElementById("button4").click();
document.getElementById("button5").click();
document.getElementById("button6").click();
document.getElementById("button7").click();
}
</script>
<input name="TestALL" type="button" value="TestALL" onclick="javascript:test_all();"/>
<table width="894" border="1">
<tr>
<th width="94" scope="row">TestCase</th>
<th width="174" scope="row">Aim</th>
<th width="174" scope="row">input</th>
<td width="194">expect output </td>
<td width="192">actual output </td>
<td width="10">Run</td>
<td width="10">Pass?</td>
</tr>
<tr>
<th scope="row">1</th>
<th scope="row">correct</th>
<th scope="row">Username
<input name="user" id="user1" type="text" value="abc" />
<br/>
Password
<input name="pass" type="password" id="pass1" value="abc" /></th>
<td><span id="expect1">0</span></td>
<td><span id="output1"></span></td>
<td><input name="button1" type="button" id="button1"
onclick="javascript:get('user1','pass1', 'output1','expect1', 'pass_out1');" value="test" /></td>
<td><span id="pass_out1" ></span></td>
</tr>
<tr>
<th scope="row">2</th>
<th scope="row">mising username </th>
<th scope="row">Username
<input name="user" id="user2" type="text" />
<br/>
Password
<input name="pass" type="password" id="pass2" value="abc" /></th>
<td><span id="expect2">-40001</span></td>
<td><span id="output2"></span></td>
<td><input name="button2" type="button" id="button2"
onclick="javascript:get('user2','pass2', 'output2','expect2', 'pass_out2');" value="test" /></td>
<td><span id="pass_out2" ></span></td>
</tr>
<tr>
<th scope="row">3</th>
<th scope="row">mising password </th>
<th scope="row">Username
<input name="user" id="user3" type="text" value="abc" />
<br/>
Password
<input name="pass" type="password" id="pass3" /></th>
<td><span id="expect3">-40001</span></td>
<td><span id="output3"></span></td>
<td><input name="button3" type="button" id="button3"
onclick="javascript:get('user3','pass3', 'output3','expect3', 'pass_out3');" value="test" /></td>
<td><span id="pass_out3" ></span></td>
</tr>
<tr>
<th scope="row">4</th>
<th scope="row">incorrect username </th>
<th scope="row">Username
<input name="user" id="user4" type="text" value="abcd" />
<br/>
Password
<input name="pass" type="password" id="pass4" value="abc" /></th>
<td><span id="expect4">-40003</span></td>
<td><span id="output4"></span></td>
<td><input name="button4" type="button" id="button4"
onclick="javascript:get('user4','pass4', 'output4','expect4', 'pass_out4');" value="test" /></td>
<td><span id="pass_out4" ></span></td>
</tr>
<tr>
<th scope="row">5</th>
<th scope="row">incorrect password </th>
<th scope="row">Username
<input name="user" id="user5" type="text" value="abc" />
<br/>
Password
<input name="pass" type="password" id="pass5" value="abcd" /></th>
<td><span id="expect5">-40003</span></td>
<td><span id="output5"></span></td>
<td><input name="button5" type="button" id="button5"
onclick="javascript:get('user5','pass5', 'output5','expect5', 'pass_out5');" value="test" /></td>
<td><span id="pass_out5" ></span></td>
</tr>
<tr>
<th scope="row">6</th>
<th scope="row">both incorrect</th>
<th scope="row">Username
<input name="user" id="user6" type="text" value="abcd" />
<br/>
Password
<input name="pass" type="password" id="pass6" value="abcd" /></th>
<td><span id="expect6">-40003</span></td>
<td><span id="output6"></span></td>
<td><input name="button6" type="button" id="button6"
onclick="javascript:get('user6','pass6', 'output6','expect6', 'pass_out6');" value="test" /></td>
<td><span id="pass_out6" ></span></td>
</tr>
<tr>
<th scope="row">7</th>
<th scope="row"><p>Server </p>
<p>internal</p>
<p>error </p></th>
<th scope="row"><p>need to test by hand </p>
<p>Username
<input name="user7" id="user7" type="text" value="abcd" />
<br/>
Password
<input name="pass7" type="password" id="pass7" value="abcd" />
</p></th>
<td><span id="expect7">-40002</span></td>
<td><span id="output7"></span></td>
<td><input name="button7" type="button" id="button7"
onclick="javascript:get('user7','pass7', 'output7','expect7', 'pass_out7');" value="test" /></td>
<td><span id="pass_out7" ></span></td>
</tr>
</table>
</body>
</html>
use rude::cgi in fastCGI
1) rude::cgi use singleton pattern , which doesn't work under fastCGI, because fcgi need to create new instance each time to parse new request. So I modify rude's constructor and destructor, make it destroy the instance after use.
2)fastCGI replace the stdio.h, and most of its functions. so where rude::cgi uses stdio.h, put #include
I am enjoying fast speed of fastcgi, while easy programming with rude::cgi.
ps:I have tried to use qDecoder, also patch a similar modification, but it doesn't work for fcgi (giving a signal 11, SIGSEG ). but it works under cgi mode. I have no idea.
Monday, June 25, 2007
Monday, May 21, 2007
Isolate your problem when debug
Everything is a feedback system
想一下你考虑一下亚马逊、雅虎这些网站,如果这些网站没有用户的话,那么这些网站就 什么都不是了。网站一开始是和报纸一样的,提供信息,有人来看。这是单向的交流,但是现代的网络来说,它比之前要更简单来维护了,因此你只需要有很多的理 念和环境,很好的气氛,这样每个人在你网站上的点击都可以帮助你把网站变得更好。受关注程度越来越高,所以每次用户的互动可以使网站变得更好。说道雅虎问 答的网站,也变得越来越好了。
feedback 在计算机发展中有着很重要的地位,从小小的精元到庞大的系统,都是依靠feedback是运行更精确.
PS: 正在阅读 the dream machine
Sunday, April 29, 2007
how many GDP is wasted on GRE / TOEFL?
the new three month TOEFL schedule was published yesterday, and it's already full last night. You can't tell how many people are waiting for the registration, and how many can't find a sit.
That's why New East get the huge market for preparing the test.
But...how many time have been spent (or wasted?) on these English test? how many GDP spend on it? and how much we can produce if we don't do such things.
Sunday, April 15, 2007
Hum, SUN JAVA JDK 1.5 bug on linux
Haha, this is not JDK's bug, its our code's problem.
we use fdopen on a socket fd twice, and fclose it twice which will close the fd as well.
when the fd is close once, system may reuse it for another socket, and we close other socket's same fd num again. brings the problem.
====================================================================
causing our file close exception, and mix different fd's content with each other, put what I write to a file into a socket!
we upgrade to JDK 1.6, hoping those bugs are fixed and not bringing in some new bugs.
seems some one has met the same problem:
http://256.com/gray/docs/misc/java_bad_file_descriptor_close_bug.shtml
Java Bad File Descriptor Close Bug
We have been fighting for a number of weeks with a bad file descriptor bug on a search project at work. Although we initially assumed it was our buggy software to blame, a closer look at the problem seems to point elsewhere. Our current research seems to indicate that a bug in Sun's JDK under Linux (maybe others) is at fault here.
Background
We have been seeing a large number of the 'Bad file descriptor' exceptions in various places around our software. We initially thought that we were someone double closing or otherwise improperly using file handles. However, after a more aggressively review of the code in question as well as the JDK, we came to the conclusion that aside from creating input or output streams using the FileDescriptor constructor (which we were not doing) there should be no way to get these problems. In addition, many of the places which were throwing the exceptions (see below) were in 3rd party libraries including Lucene and Berkeley Database JE.
Our application is a search system which is using ActiveMQ JMS to receive, index, and store documents. We use 10s of JMS queues and topics to coordinate a distributed collection of search nodes. This translates into 10s of sockets which are mostly TCP but some UDP and multicast packets. Local disk descriptors to standard SCSI disks or hardware/software raid configurations. No network filesystems are being used. Mostly EXT3, some XFS, and Some temporary filesystems but otherwise nothing exotic.
Possible Solution
As of February 26, 2007, more testing has revealed that our problems seem to be coming from concurrency issues in Sun's 1.5 JDK (through v.11) combined with Lucene v2.0's calling close() in FSIndexInput.finalize() and FSIndexOutput.finalize() methods -- a real no-no. Looks like v2.1 has 2 bug fixes that would resolve this (669 and 750). We think that the problem is a race condition between a user thread which has caused close and the finalizer which is also calling close. The fact that the FileDescriptor has already been closed is not properly synchronized between the 2 threads so a double close is performed, closing a file that was just opened.
This problem also seems to be fixed in Sun's v1.6 JDK. Looking through the change logs, we see that a number of garbage collection bugs have been fixed. Right now our speculation is that the problems stem from a synchronization bug in 1.5 versions between the GC (maybe just the finalizer parts) and user threads. The finalizer thread does not know that a user thread had closed a file descriptor -- or vice versa. Although we are seeing 30%+ worse performance with 1.6, we have not seen any Bad File Descriptor exceptions. If they fixed some problems by adding synchronization or memory barriers to the GC, this also may account for the performance losses.
JDK Analysis
One of the things that we noticed in looking at the JDK is that if the close() system call fails, the FileDescriptor is not reset to -1 even though the system's file descriptor is invalid (see Linux kernel source). This could mean that if the close syscall fails, it might cause a close of either an invalid file descriptor, or a valid descriptor which happened to call open and get the latest file descriptor that was just closed. This may be the ultimate problem although we are unsure of when, aside from NFS which we are not using, close returns failure. This bug was not in Sun's 1.4 JDK, but was introduced in 1.5 when the error code from close was detected. The bug in is all 1.5 versions through 1.5.11 as well as 1.6. Since the Linux version is using the Solaris code for close, we wonder if the Solaris kernel does something different of it the Solaris version has a bug as well.
We decided initially to copy and override the FileDescriptor class and the classes which open them so we can instrument, and hopefully protect against, the problems. We also wanted to put some synchronized blocks around the closes to make sure that we don't have a concurrency problem. Initial takes at this seemed to have reduced but not removed the problems. As of February 2007 we are working on rev 3 of these classes however these were unable to fix the problem although they gave us more information of the call graphs at fault.
Linux Kernel
Below is the source for the close() syscall from the 2.6.18.3 Linux kernel. As you can see, if the file descriptor is valid, there is no way to leave this routine without it being closed and made available for the next call to open(). If filep_close returns an error, and the JDK does not set the file descriptor to -1, a double close will most likely happen in the future.
asmlinkage long sys_close(unsigned int fd)
{
struct file * filp;
struct files_struct *files = current->files;
struct fdtable *fdt;
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
if (fd >= fdt->max_fds)
goto out_unlock;
filp = fdt->fd[fd];
if (!filp)
goto out_unlock;
rcu_assign_pointer(fdt->fd[fd], NULL);
FD_CLR(fd, fdt->close_on_exec);
__put_unused_fd(files, fd);
spin_unlock(&files->file_lock);
return filp_close(filp, files);
out_unlock:
spin_unlock(&files->file_lock);
return -EBADF;
}
Updated news:
I replaced the JNI part with pure Java socket, and it works fine now. Oops.
And here comes another challenge, how to stop those complicate sub-thread safely.
blogger is BANed from China
Thursday, March 29, 2007
Tuesday, March 27, 2007
Why can't my blog be visited?
Sunday, March 18, 2007
Find out who is viewing your blog
I can find out people from where, through what way find my blog.
currently, some people from Japan, Australia , US have visited.
they are looking for LSH, VTune, kerrighed, openMosix, openSSI.
it's great to find people with the same interest.
What do berkeley CS student read?
http://www.cs.berkeley.edu/~christos/classics/cs298.html
Examples of classics:
- Euler's paper on the Konigsberg bridges; do you know of a translation? (or Latin?)
- On computable numbers, with an application to the Entscheidungsproblem. Alan Turing 1936
- As We May Think. Vannevar Bush, 1945
- First Draft of the Report on EDVAC. John von Neumann 1946
- A Mathematical Theory of Communication. Claude E. Shannon 1948
- The Turing Test paper, Alan Turing 1950
- Non-Cooperative Games. John Nash, 1951
- Letter from Gödel to von Neumann, 1956; see J. Hartmanis's "Godel, von Neumann and the P=?NP problem," Bulletin of the European Association for Theoretical Computer Science (EATCS), 38 (1989), pp. 101--107.
- Edmonds, Jack , Paths, trees, and flowers, Canadian Journal of Mathematics, Vol 17, No -, 449-467, 1965
- Three papers on NP-completeness: S. A. Cook The complexity of theorem-proving procedures, 1971 STOC; R.M. Karp. Reducibility among combinatorial problems. In R.E. Miller and J.W. Thatcher, editors, Complexity of Computer Computations, pages 85--103. Plenum Press, 1972; and Levin, Universal Search Problems. [Problemy Peredatsi Informatsii] 9(3):265-266, 1973 (c). Annals of the History of Computing 6(4):384-400, 1984.
- Two papers on the relational model
- A Relational Model of Data for Large Shared Data Banks. E. F. Codd 1970
- Relational Completeness of Data Base Sublanguages. E. F. Codd, 1972
- New Directions in Cryptography, Diffie and Hellman, 1976
- Simulating physics with computers. Feynman, IJTP 21 1982
What do you work for?
If you work for living, you may work hard, but you will find the work boring.
If you don't have to worry about life, why will you work?
And what do you live for?
Thursday, March 15, 2007
Quick Tips On Raising Startup Funding Without A Plan Or A PowerPoint
Have A Story
Demonstrate Leverage
Accept That Your Baby Is Ugly
Dream Big, But Plan Small