Angelo's Soapbox

Wednesday Aug 27, 2008

Engineering Webcast: OpenSolaris, A Boundless Development System

Time for some shameless plug. I host a engineering webcast where I get to talk with some pretty cool folks. We just released one more of these webcast. This one talks about OpenSolaris. If you are a developer you need to check this one out. Both Hugo and Marty are exciting speakers. In this talk we some details on both the technical and business side of OpenSolaris. Enjoy

http://www.snpnet.com/customer_pub/sun/ISV_OpenSol/

So what else would you like to hear about!

Tuesday Jul 15, 2008

DTrace screencast

Its been a while since I blogged here. So wanted to do blog some good content. I work in the Open Source team at Sun and I'm focusing on Emerging Markets. Its a pretty exciting work and I'm enjoying very bit of it.

Recently I came across an open source project called the "Jing Project". Jing makes creating screen casts a breeze. I've been playing with it and created a few screen casts to demonstrate DTrace. If you have not seen DTrace in action here is your chance.

To make it easy for download and viewing the screen cast has been split into 5 parts. Easy on the bandwidth and easy on the eyes. So without much more ado here are the screen casts. Enjoy and provide feedback.

DTrace screen casts
Name Description
Introductory Presentation 01-Intro.swf
Observing System calls 02-demo-syscall1.swf
System call arguments 03-demo-syscall2.swf
Library calls and arguments 04-demo-libc.swf
DTrace and JavaScript 05-demo-javascript.swf


You may need a flash player to view these screen casts.

I plan to do DTrace tutorials in the next series of screen casts. Enjoy and don't forget to provide feedback.

Tuesday May 22, 2007

DTrace meets the AMP (Apache MySQL PHP) stack

During JavaOne this year Rags and I did a hands on lab on DTrace. The topic was "Using DTrace on Java and other Web 2.0 Languages in Solaris". Due to some unforeseen reason the lab was scheduled from 8:45 PM to 10:45 PM (Yes PM) and that to on the day of the big party at JavaOne. So I was expecting to be speaking to an empty room but lo and behold we had close to 100 engineers ( a few pretty drunk) and most stayed until the finished the lab.It was pretty heartening and was worth all the efforts that went into it.

One of the highlights of the lab was a script that we developed. It lists the JavaScript & PHP function entry and MySQL SQLs that happen live system. You need the following prerequisite for the script to be fully functional.

Here is the script. It takes one argument - the pid of the mysqld process in your system.

#!/usr/sbin/dtrace -ZqFs
/* We use terminal escape sequence to change color
 * Javascript - Red
 * PHP - Blue
 * MYSQL - Green
 */
 
trace_mozilla*:::js_function-entry
{
        printf("\033[01;31m%s\033[0m\n",copyinstr(arg2));
}

trace_mozilla*:::js_function-return
{
        printf("\033[01;31m%s\033[0m\n",copyinstr(arg2));
}

php*:::function-entry
/arg0/
{
        printf("\033[01;34m%s\033[0m\n",copyinstr(arg0));
}

php*:::function-return
/arg0/
{
        printf("\033[01;34m%s\033[0m\n",copyinstr(arg0));
}

pid$1::_Z16dispatch_command19enum_server_commandP3THDPcj:*
{
        self->sql = copyinstr(arg2);
        printf("\033[01;32m%s\033[0m\n",self->sql);
}

 You will see a nice color coded output. Javascript calls in Red, PHP in Blue and MySQL in green.

In subsequent blogs I try and go through the process of developing this code. Meanwhile enjoy Solaris DTrace

I met Vinod Khosla

During JavaOne this year Rags and I went to a nice South Indian restaurant, Dosa, in San Francisco. This is an excellent place by the way and I highly recommend it. I was looking around and it seemed like we were the only PIO (Persons on Indian Origin) around until I spotted a family sitting just behind us. On closer observation it looked like someone familiar. I checked twice and quitely told Rags, "Hey Vinod Khosla is sitting behind us?"

We debated for a few minutes if it was right to intrude but better wisdom prevailed and we walked up to him and actually shook his hands.He was pretty gracious and freely chatted with us. This was definitely one of the highlights of JavaOne for me.

For those of you who do not know Vinod, he is the founder of Sun He is also the founder of Daisy Systems and Khosla Ventures and help start companies like Juniper networks and Excite etc. See his WikiPedia Entry for more details.

Monday Apr 02, 2007

DTrace, April Fools and Solaris 10 Binary Compatability.

Its been a while since I blogged. Its definitely not for lack of content but lack of the discipline to sit down and "just do it". Well its about time.

Its rare to get an opportunity to talk about such varied topics such as Solaris Binary Application Guarantee , DTrace and April fools all in one blog. So it would be a shame if I let it pass.

I work in the ISV engineering team in Sun and as you may have guessed we work with Sun's software partners - ISVs (Independent Software Vendors). One of the things that I noticed was that some of our partner applications would fail to install on Solaris 10. This was frustrating to me as the problem was not with the partner application but their installer. Typically the installer fails when it find that the Solaris version is 10. If only I could get past the installer issue I'd have a an application that works perfectly fine.

So I wrote a simple D-script to fool the installer into thinking it is a Solaris 9 machine. You can try this the next time you find yourself struggling with an program that insists on a older version of Solaris.


#!/usr/sbin/dtrace -qs

#pragma D option destructive

BEGIN
{
        printf("Changing output of uname for pid %d and its descendants...\n",$1);
}

syscall::uname:entry 
/progenyof($1)/
{
        self->addr = arg0; 
}

syscall::uname:return
/progenyof($1)/
{
        copyoutstr("5.9", self->addr+(257*2), 257);
}


This script expects the pid of a shell as its only argument and it will change the uname version to 5.9 for this shell and all its descendants and as with all D-scripts once you stop this script (with a ^c) everything would be back as it was before.

Enjoy!

Wednesday Nov 15, 2006

Solaris presentation at Colby College

Yesterday I had an excellent opportunity to present DTrace and ZFS at Colby College . There were folks from the CS department and IT dept. It was very heartening to see the interest in Solaris. The lecture was part of their CS Colloquium.

Presenting to CS students is always a challange. They seem to come up with a unique set of questions. The student generally are not "corrupted" by the rigors of  IT world and they tend to ask more "why" rather than "how" questions.

After a pretty detailed presentation my resources slide had just one entry http://opensolaris.org/  Everything you need to know about DTrace and ZFS is in OpenSolaris. If you've not been there at OpenSolaris recently check it out.

Tuesday Aug 01, 2006

DTrace could have saved the Vista Voice Recognition Demo

Looks like Microsoft has an unfair share of unfavorable visits from the demo gods. For example just last week a demo of the Voice recognition feature of Vista went horribly bad and a video of the failed demo was all over the net. Google Video , Slash Dot and YouTube all have helped to spread the video around. I just came across Microsoft's Larry Osterman's blog. He claims responsibility for the snafu and explains the details of why this went wrong. While there is a lot of good info in the blog that may be of interest to a analog audio engineer the following line in his blog caught my attention. The annoying thing about it was that the bug wasn't reproducible - every time he stepped through the code in the debugger, it worked perfectly, but it kept failing when run without any traces. I'm sure we all have faced similar problems. They seem to go away as soon as you attach a debugger to it or even add some custom instrumentation (printf) to the application. In this case the problem was occurring if they had a positive feedback loop and the problem was very time sensitive. Solaris 10 Dynamic Tracing or DTrace in short is absolutely the best tool in the market today to diagnose such problems. It frees you from having to do custom instrumentation and helps you diagnose problems in a live production setting without incurring the overhead of traditional debuggers. Now if only Vista had DTrace! Larry could have diagnosed the problem without having to incur the big cost of a stepping through the debugger. To learn more about DTrace see Solaris 10 Dynamic Tracing Users Guide DTrace Webcast - (shameless self promotion) Brendan Greggs DTrace Toolkit Tags: ,

Friday Jul 21, 2006

How to cube a mango?

Edward Tufte' for a seven year old. Last night at the dinner table we had a treat for the kids. My wife had bought a box of mangoes and I was asked to slice it up for the family. We normally just make slices and the kids have fun just scooping the flesh out with a spoon but yesterday I decided to make cubes. My 7 year old was carefully watching me cube the mango. She was pretty excited about the process and wanted to remember it. So she illustrated the process. I was pretty impressed. If only we can get technical docs illustrated so clearly !!!

Tuesday May 02, 2006

10000 DTrace webcast downloads!

Time for some gloating about the popularity of DTrace and a bit of joy about a personal milestone. For most of last year I've been evangelizing the capabilities of Solaris 10 Dynamic tracing technology DTrace, among Sun's partner community. Most of the effort has gone into in person presentations, which has been by far the most rewarding. Just to see the amazement on peoples faces when the realize the power of the tool is worth every second of effort that goes into these presentations. But with three kids at home, traveling can be very disruptive. So I've been trying to use technology to advance the cause. We did webcasts and Hands on Lab and gave the presentation material to other able presenters. The webcasts and Hands on Labs are freely available on the net. Last week we reached an exciting milestone. Over 10,000 (yes 4 zeros) people have downloaded and viewed the webcast. If you have viewed the Webcast I'd like to hear from you.Email me at angelo dot rajadurai at sun dot com. Let me know if you liked it. What types of other material would you like to see on DTrace? If you are interested in DTrace and have been looking to learn about its capabilities here are a few resources for you. DTrace webcast Hands on Labs DTrace BigAdmin site DTrace community on OpenSolaris.org Brendan Gregg's DTrace tools Solaris 10 Dynamic Tracing (DTrace) guide

Technorati tag:

Tuesday Apr 04, 2006

DTrace detective!

Recently I got a request from a coworker. The email Subject line said, "Solaris has a mind of its own". Basically looks like something or someone was creating a link from /etc/motd to a file in /var/spool on his cutsomers system. The customer removes the link and replace /etc/motd with a blank file several times a day and the link keeps reappearing again. So the question was can I help find the culprit? These days DTrace seems to be the answer for every question on Solaris 10. At least that is the first thing that comes to my mind. My Acer Ferrari running the latest version of  Solaris Express comes in handy as a test bed for my detective work. For starters I think symlink(2) system call is called when someone creates a link in the system. To verify that I ran the following one liner on  one window when I created a link on a another window. dtrace -n syscall::symlink:entry
dtrace: description 'syscall::symlink:entry' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0  45294                    symlink:entry

OK this looks like it is working. Now lets see if we can track down the file names that are being linked. man page of symlink(2) says that the arg0 and arg1 has the names of the file being linked. So I figured that the following script should do the trick. dtrace -qn syscall::symlink:entry'{printf("linking %s to %s\n",copyinstr(arg0), copyinstr(arg1));}'
Well lets try it. Run the above script and then do a link. (ln -s xxx yyy) bash-3.00# dtrace -qn syscall::symlink:entry'{printf("linking %s to %s\n",copyinstr(arg0), copyinstr(arg1));}'
linking xxx to yyy
That looks great. Just a few point. -q option is to ask DTrace to be quite. Telling it to print only want you want and not what it thinks you want. copyinstr is needed because the file name is in user land and DTrace runs in the kernal address space. So we now have the basic building block for our script. For starters lets make the script look a little more pretty. I'm not going to send a command line to the customer. They deserve better. So here is a script.
#!/usr/sbin/dtrace -qs
syscall::symlink:entry
{
        printf("Someone is linking %s to %s\n",copyinstr(arg0),copyinstr(arg1));
}


Put it into a file and give it permission to execute (chmod a+x ). I called the script wholink.d bash-3.00# ./wholink.d
Someone is linking xxx to yyy
Ok we now have a pretty looking script. Lets make it more useful. First we need to narrow down the script to only pinpoint links to /etc/motd. Predicate shelp us achieve this.
#!/usr/sbin/dtrace -qs
syscall::symlink:entry
/copyinstr(arg1) == "/etc/motd"/
{
        printf("Someone is linking %s to %s\n",copyinstr(arg0), copyinstr(arg1));
}

Look like this works. I tried with the command ln -s /tmp/xxx /etc/motd bash-3.00# ./wholink.d
Someone is linking /tmp/xxx to /etc/motd
Just one point to note. If I change my link command to (cd /etc ; ln -s /tmp/xxx motd)my script would not catch the link so one small mod is needed. I used the basename to just look for the file name and weed out the directory name. Yes there could be some false possitives when someone links a motd file in other locations. In this case I feel getting a few extra flase positives would not be too much of an issue. Ofcourse there are ways to narrow this down to only /etc/motd. Let me know if you are interested. Or may be I'd blog about that one a little later. So for now changing the script as follows... #!/usr/sbin/dtrace -qs

syscall::symlink:entry
/basename(copyinstr(arg1)) == "/etc/motd"/
{
        printf("Someone is linking %s to %s\n",copyinstr(arg0), copyinstr(arg1));
}

Now that we have the culprit lets set a trap to find more about the process that is doing this link. Lets collect the pid, execname, and time when the link happened. Here is the script that prints these details. #!/usr/sbin/dtrace -qs
syscall::symlink:entry
/basename(copyinstr(arg1)) == "motd"/
{
        printf("Caught the culprit\n");
        printf("%20s\t %-20Y\n", "Time",walltimestamp);
        printf("%20s\t %-10d\n", "Process id",pid);
        printf("%20s\t %-20s\n", "Name of Executable" ,execname);
}
Running the script produces the following output.
bash-3.00# ./wholink.d
Caught the culprit
                Time     2006 Apr  4 13:48:46
          Process id     11007
  Name of Executable     ln

Ok this gave some info but I don't think any of this very helpful. I'd like to know who called ln. So would like to run ptree and see the process tree for that given process. Well we are in luck. DTrace allows us to run any unix command using the system method. So I modified the script. Please note DTrace is meant to run on a live production system. In order to avoid accidental modification to the system th,e ability to run system is disabled by default. You need to enable it using the -w option. So here is the modified script... #!/usr/sbin/dtrace -wqs
syscall::symlink:entry
/basename(copyinstr(arg1)) == "motd"/
{
        printf("Caught the culprit\n");
        printf("%20s\t %-20Y\n", "Time",walltimestamp);
        printf("%20s\t %-10d\n", "Process id",pid);
        printf("%20s\t %-20s\n", "Name of Executable" ,execname);
        system("ptree %d",pid);
}

When I tried runing this script for some reason ptree did not show any output. This is no good. It baffled me for a few minutes till I realized that the ln process was completeing before DTrace could get a chance to start the ptree command. Huh! you slimy culprit! Fear not brave detective. DTrace can help. Introducing the stop() method. It allows you to stop the process. We then do the ptree. I'd like to let the "ln" process to continue once we collect info. This is to avoid any other process that is doing the link from hanging. We have a law here against cruel and unusual punishment, you know.
#!/usr/sbin/dtrace -wqs
syscall::symlink:entry
/basename(copyinstr(arg1))=="motd"/
{
        printf("Caught the culprit\n");
        printf("%20s\t %-20Y\n", "Time",walltimestamp);
        printf("%20s\t %-10d\n", "Process id",pid);
        printf("%20s\t %-20s\n", "Name of Executable" ,execname);
        stop();
        system("ptree %d",pid);
        system("prun %d",pid);
}
Now the question that you have been waiting for, "Who is the culprit?" Sorry folks we take our customers info very seriously and we protect the innocent (or the guilty)!!! Just for fun I added a small variation of this script to see if we can outrun the culprit and keep /etc/motd safe. Here is the script. Try it! let me know if you can figure out how this work.
bash-3.00# cat stoplink.d
#!/usr/sbin/dtrace -wqs
syscall::symlink:entry
/copyinstr(arg1)=="/etc/motd"/
{
        printf("Caught the culprit\n");
        printf("%20s\t %-20Y\n", "Time",walltimestamp);
        printf("%20s\t %-10d\n", "Process id",pid);
        printf("%20s\t %-20s\n", "Name of Executable" ,execname);
        copyoutstr("/tmp/motd",arg1,9);
        stop();
        system("ptree %d",pid);
        system("prun %d",pid);
        system("rm /tmp/motd");
}

Friday Jan 13, 2006

I'm a bona fide inventor

Happy New Year everyone. I'm happy to report that I'm now a bona fide inventor. Our patent for "Rating apparatus and method for evaluating bugs" was granted end of December.

Friday Nov 04, 2005

Solaris 10 DTrace Code Camps, Webcast & Hands on labs

In the last few months I've been presenting DTrace to many developers and System Admins around the world. Its been a great to talk about this very cool technology. The feedback from the developer community has been wonderful. Code Camps are an excellent format to present DTrace. 30 to a 100 developers get together. Each of them have a Solaris 10 desktops. We spend the whole day talking about DTrace and Zones . The first hour is dedicated to Solaris 10 introduction. We then have 4 hours of DTrace. Developers get to ask questions and I get to write D-scripts to show them how to answer such questions live. Then the rest of the day is spent talking about Zones and SMF. Developers sometimes bring in their applications on their Solaris 10 laptop. These lucky once get a taste of how DTrace can be used to better understand their application. Some where between all this we get good lunch at Sun's expense and snacks and ofcourse lots of coffee. If you did not get a chance to attend one of these camps, you can atleast look at the presentation.

Please provide feedback on these slides. There is always room for improvment. By the way I've been busy with other forms of presentation as well. If you are new to DTrace you may find my DTrace webcast very useful. Actualy over 2500 people have viewed it already. Again your feedback is very welcome. If you are more of the "lem'me me try for myself" type of person you may find the Hands on Labs more to your liking. Just download the zip file. Unzip it and point your browser to the index.html file. There are step by step instructions with lots of screen shots to help you walk through DTrace basics. All you need is a Solaris 10 system. If you do not have one just it. Solaris 10 run on a boat load of hardware. Chances are your systems is on the supported list .

Technorati tag:

Thursday Nov 03, 2005

Takin' the plunge

Its 'bout time! Have been thinking about blogging for a while. In fact its been over 3 months since I set up the account. So its 'bout time I get started. Here goes A little about myself. I've been at Sun for almost 13 years. Started here as part of the product team during the early days of Solaris x86. Spent a lot of time working with developers and Sun's large partners. Right now I'm part of the Tech Office in Sun's Market Develeopment Engineering organization. My group "makes strategic partners run best on Sun." We help port partner applications to our platform, performance tune their application, help partners size their application, benchmark their application and anything else that will help make Sun the best platform for our partners. Its an exciting job at Sun at an exciting time. One of my job responsibilities is to run the Tunathon 2006 program. We get engineers from the product team to tune partner applications. This gives Sun product engineering a view into how our partners use our platform and it gives partners access to the big brains at Sun. The last 5 months I've been traveling around the world (9 countries) and spoke to over a 1000 developers and sysadmins about the virtues of DTrace. Its been a great experience and I plan to document these in my blogs. On a personal front I'm a father of 3 (You'd never say that if you saw me!!!). My oldest is in fifth grade and is a Math wizz and is preparing for his first spelling bee. My 6 year old is into music, plays the piano and dabbles with composing songs. My 2 year old, is well..., very cute. My wife holds a post graduate degree in Electrical Engineering and she decided to stay back home to be with the kids for now. My Father retired as the Chairman and Managing Director of a Public Sector Company in India. OK enough about myself.


Archives
Links
Referrers