Friday, August 08, 2008

Mac is on BSD!

First time experience BSD's power on networking project. Comparing to Linux's up to 10% tcpdump package loss, BSD is ZER0!
And Mac is built base on BSD! What a amazing discovery.

Tuesday, April 01, 2008

blogger is unblocked?

I did a search of "bad file descriptor" and found my block listing No.3!
What's more, I can open it!

Friday, November 16, 2007

Sophy


Sophy
Originally uploaded by StarGirl714
Isn't my girl lovely?

Tuesday, October 16, 2007

I am back

In fact, Blogger is back in China.

Saturday, October 13, 2007

Don't use directly the sample code in your real life project

most sample code doesn't handle error, the simply show you how to use a function.
of course they use their functions correctly, but they may need others' functions to make their functions run. Here is the problem, they may not use others right.

Saturday, September 22, 2007

One Anti-Piracy System to Rule Them All

September 21, 2007, 4:31 pm
One Anti-Piracy System to Rule Them All

By Brad Stone

Tags: Audible Magic, digital fingerprinting, MPAA, vobile

Hollywood appears to have a preliminary winner in its bake-off of anti-piracy technologies.

For the last year, the film industry, through its Palo Alto-based R&D joint venture MovieLabs, has been testing a dozen so-called “digital fingerprinting” technologies. The technology purports to scan file sharing sites, Internet providers and peer-to-peer networks to identify copyrighted material.
fingerprinting technologies“Fingerprinting Performance” (Leonard Kleinrock, 2007)

Yesterday in Los Angeles, people affiliated with the Motion Picture Association of America talked about the ongoing tests at a day-long anti-piracy workshop that the MPAA co-hosted with the University of California. In his introductory keynote at the event, UCLA professor and Internet pioneer Leonard Kleinrock showed a single slide that suggested that one of the anti-piracy filtering companies had outperformed the other 11, with the highest number of matches of infringing content and lowest number of false-positives. But professor Kleinrock and MPAA execs declined to name the participating companies or who had scored best on the test, saying that secrecy was a precondition for their participation in the tests.

Nevertheless, afterwards, executives from Santa Clara, Calif-based Vobile were crowing in the hallways of the Universal Hilton Hotel.

The two-year old company’s technology, called Video DNA, has apparently bested others from the Royal Philips Electronics, Thomson Software & Technology, and the highest profile digital fingerprinting company, the Los Gatos, Calif.-based Audible Magic, which has deals to filter video sharing sites like YouTube and Microsoft’s Soapbox.

The MPAA told Business Week in the spring that Vobile was doing “very well” on the tests.

Movie Labs stress-tested the anti-piracy systems by loading hundreds of hours of copyrighted video content into the databases of the various filters, and then by flooding them with thousands of video files, some distorted, darkened and cropped, to try to scuttle their ability to find matches.

In the next phase of the ongoing tests, MovieLabs will see if the systems can handle ever larger quantities of copyrighted works. Theoretically, adding more songs, TV shows and movies in their databases could slow down these systems—and the Internet video sites that use them— since it could take longer to find possible matches.

MovieLabs has been sharing tests results with its member movie studios since the summer. MovieLabs chief executive Steve Weinstein says the technology is ready for prime time. “In a year you’re going to see many Internet companies using it. This technology has shown its viability.”

* Link
* E-mail this

*
*

* Internet, Music and Video, Audible Magic, digital fingerprinting, MPAA, vobile

Sunday, August 12, 2007

is the rumer ture? Google will use flash to cross platform

Google is going to occupy all OS platform by flash? It doesn't need its own operating system to compete with Microsoft / MacOS / Linux. But with flash, its software can run every where, also in mobile phone!

I just saw gtalk in flash..

Wednesday, July 25, 2007

what I did last year?

C code : 13000 lines
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

I was writing a simple program, open a file, read the data. Each data structure is n bytes.
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

Moshe Bar, openMosix founder and project leader, also engage Xen, KVM, has decided to close openMosix, and focus on single machine's 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

hum, finally feel why drawing UML is helpful. since it can generate code (the dumpy and duplicate part), release programmer's work. And you have a cool drawing and deep thought before coding. :)

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

Ha~ I wrote a AJAX web page last night, which will run several cases, each post different data to my fcgi program, and check the return value, then output PASS or FAIL. And a simple synchronize for separate running tests.
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

rude::cgi was designed for CGI. when I put it in use for my fastCGI program, I make it a patch.
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 before #include . that will work.

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

How to give credit to other's skype ?

Call me~ Skype id: zheng.walter

Monday, May 21, 2007

Isolate your problem when debug

When you combine your code with the others, and it crashes, you should isolate your code and the other's to reproduce the crash. so that you can find the spot.

bloger's bug

Everything is a feedback system

link: http://news.csdn.net/n/20070519/104271.html
想一下你考虑一下亚马逊、雅虎这些网站,如果这些网站没有用户的话,那么这些网站就 什么都不是了。网站一开始是和报纸一样的,提供信息,有人来看。这是单向的交流,但是现代的网络来说,它比之前要更简单来维护了,因此你只需要有很多的理 念和环境,很好的气氛,这样每个人在你网站上的点击都可以帮助你把网站变得更好。受关注程度越来越高,所以每次用户的互动可以使网站变得更好。说道雅虎问 答的网站,也变得越来越好了。

feedback 在计算机发展中有着很重要的地位,从小小的精元到庞大的系统,都是依靠feedback是运行更精确.

PS: 正在阅读 the dream machine

Sunday, April 29, 2007

how many GDP is wasted on GRE / TOEFL?

Recently, I found that it really really hard to find a open sit for GRE / TOEFL test.

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

Latest update: 2008-4-9
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

What the F**K! I can't visit my blog from China. And won't be able to update it for a long time.